예제 #1
0
        public void Serialize_Desirialize()
        {
            // NOTE: Watch that all properties LogEntryData have non default values.
            var serialized = new LogEntryData("somedate", true, AccessType.REGISTRY, @"d:\my documents\pics", @"c:\win\malware.exe");

            var data         = LogEntryData.Serialize(serialized);
            var deserialized = LogEntryData.Deserialize(data);

            Assert.IsTrue(PropertyComparer.AreEqual(serialized, deserialized));
        }
        public void FindCarsByLicensePlateTest_AllVehicles()
        {
            var expect = new List <Vehicle>
            {
                new Car
                {
                    Manufacturer   = "VW",
                    Model          = "Käfer",
                    LicensePlate   = "K-GS-01",
                    Year           = 1965,
                    NewPrice       = 9999m,
                    Capacity       = 1000,
                    Power          = 30,
                    PollutantClass = PollutantClasses.Normal
                },
                new Car
                {
                    Manufacturer   = "Opel",
                    Model          = "Kadett",
                    LicensePlate   = "K-GS-02",
                    Year           = 1964,
                    NewPrice       = 12000m,
                    Capacity       = 1600,
                    Power          = 60,
                    PollutantClass = PollutantClasses.Diesel
                },
                new Motorcycle
                {
                    Manufacturer = "BMW",
                    Model        = "R1200r",
                    LicensePlate = "K-GS-03",
                    Year         = 1999,
                    NewPrice     = 6000m,
                    Capacity     = 1170
                },
                new Truck
                {
                    Manufacturer = "Mercedes",
                    Model        = "LG 315",
                    LicensePlate = "K-GS-04",
                    Year         = 1960,
                    NewPrice     = 23000m,
                    Axis         = 2,
                    Payload      = 5.5
                }
            };
            var sut = VehicleManagerFactory.Create(null);

            var result = sut.FindCarsByLicensePlate("");

            Assert.IsTrue(PropertyComparer.AreEqual(expect, new List <Vehicle>(result.Keys)));
        }
예제 #3
0
        public void Refresh()
        {
            var logViewModel = new LogViewModel(eventLog);
            // This entry will not be displayed, until user not clicked "Refresh".
            var bytes =
                LogEntryData.Serialize(new LogEntryData(DateTime.Now.ToShortTimeString(), false, AccessType.FILESYSTEM,
                                                        "hello", "hello2"));

            EventLog.WriteEntry("APTester", "Hello world!", EventLogEntryType.Information, 0, 0, bytes);

            // Emulate click on "Refresh" button.
            logViewModel.Refresh();

            // Assert
            // Check the equality of logView.Data and eventLog.Entries.
            for (var i = 0; i < eventLog.Entries.Count; i++)
            {
                Assert.IsTrue(PropertyComparer.AreEqual(LogEntryData.Deserialize(eventLog.Entries[i].Data),
                                                        logViewModel.Data[i]));
            }
        }
        public void FindCarsByLicensePlateTest_OneCar()
        {
            var expect = new List <Vehicle>
            {
                new Car
                {
                    Manufacturer   = "Opel",
                    Model          = "Kadett",
                    LicensePlate   = "K-GS-02",
                    Year           = 1964,
                    NewPrice       = 12000m,
                    Capacity       = 1600,
                    Power          = 60,
                    PollutantClass = PollutantClasses.Diesel
                }
            };
            var sut = VehicleManagerFactory.Create(null);

            var result = sut.FindCarsByLicensePlate("k-gs-02");

            Assert.IsTrue(PropertyComparer.AreEqual(expect, new List <Vehicle>(result.Keys)));
        }