// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
//go:build windows
// +build windows
package wineventlog
import (
"encoding/xml"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUnmarshalWinEvtRecord(t *testing.T) {
tests := []struct {
xml string
wEvtRecord windowsEventLogRecord
}{
{
xml: `
2022-10-28T22:33:25Z
RulesEngine
2
`,
wEvtRecord: windowsEventLogRecord{
EventData: EventData{
Data: []Datum{
{"2022-10-28T22:33:25Z"},
{"RulesEngine"},
{"2"},
},
},
},
},
{
xml: `
0
2022-10-26T20:24:13.4253261Z
`,
wEvtRecord: windowsEventLogRecord{
UserData: UserData{
Data: []Datum{
{"0"},
{"2022-10-26T20:24:13.4253261Z"},
},
},
},
},
}
for _, test := range tests {
var record windowsEventLogRecord
xml.Unmarshal([]byte(test.xml), &record)
assert.Equal(t, test.wEvtRecord, record)
}
}