예제 #1
0
        public void Test_Events_Serialization <T>(Func <ProductionEventLists, IProductionEvents <T> > eventList, T evt1, T evt2)
        {
            var siteModel = new SiteModel(Guid.Empty, StorageMutability.Immutable, false);
            var events    = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            var referenceDate = DateTime.UtcNow;

            eventList(events).PutValueAtDate(referenceDate.AddMinutes(-60), evt1);
            eventList(events).PutValueAtDate(referenceDate.AddMinutes(-30), evt2);

            eventList(events).Count().Should().Be(2);

            var storageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Mutable);

            storageProxy.SetImmutableStorageProxy(new StorageProxy_Ignite_Transactional(StorageMutability.Immutable));
            events.SaveMachineEventsToPersistentStore(storageProxy);
            var resultantEvents = eventList(events); // events.GetEventList(ProductionEventType.GPSAccuracyChange);

            resultantEvents.Count().Should().Be(2);

            resultantEvents.LoadFromStore(storageProxy.ImmutableProxy);
            resultantEvents.Count().Should().Be(2);

            ((ProductionEvents <T>)resultantEvents).Events[0].State.Should().BeEquivalentTo(evt1);
            ((ProductionEvents <T>)resultantEvents).Events[1].State.Should().BeEquivalentTo(evt2);
        }
예제 #2
0
        public void Test_ProjectImmutableDataEventsTests_MachineDesignNameIDStateEvents_SaveAndLoad()
        {
            var siteModel = new SiteModel(Guid.Empty, StorageMutability.Immutable, false);
            var events    = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            DateTime referenceDate = DateTime.UtcNow;

            events.MachineDesignNameIDStateEvents.PutValueAtDate(referenceDate.AddMinutes(-60), 0);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(referenceDate.AddMinutes(-30), 1);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(referenceDate.AddMinutes(-29), 1);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(referenceDate.AddMinutes(-29), 2);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(referenceDate.AddMinutes(-29), 3);
            Assert.True(3 == events.MachineDesignNameIDStateEvents.Count(), $"List contains {events.MachineDesignNameIDStateEvents.Count()} MachineDesignName events, instead of 3");

            var storageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Mutable);

            storageProxy.SetImmutableStorageProxy(new StorageProxy_Ignite_Transactional(StorageMutability.Immutable));
            events.SaveMachineEventsToPersistentStore(storageProxy);
            var resultantEvents = events.GetEventList(ProductionEventType.DesignChange);

            Assert.Equal(3, resultantEvents.Count());

            resultantEvents.LoadFromStore(storageProxy.ImmutableProxy);
            Assert.Equal(2, resultantEvents.Count());

            resultantEvents.LoadFromStore(storageProxy);
            Assert.Equal(3, resultantEvents.Count());
        }
예제 #3
0
        public void Test_ProjectImmutableDataEventsTests_AllTypesNoDuplicates()
        {
            var siteModel = new SiteModel(Guid.Empty, StorageMutability.Immutable, false);
            var events    = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            DateTime referenceDate = DateTime.UtcNow;

            events.MachineDesignNameIDStateEvents.PutValueAtDate(referenceDate.AddMinutes(-60), 0);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(referenceDate.AddMinutes(-30), 1);
            Assert.True(2 == events.MachineDesignNameIDStateEvents.Count(), $"List contains {events.MachineDesignNameIDStateEvents.Count()} MachineDesignName events, instead of 2");

            events.GPSAccuracyAndToleranceStateEvents.PutValueAtDate(referenceDate.AddMinutes(-60), new GPSAccuracyAndTolerance(GPSAccuracy.Coarse, 2));
            events.GPSAccuracyAndToleranceStateEvents.PutValueAtDate(referenceDate.AddMinutes(-58), new GPSAccuracyAndTolerance(GPSAccuracy.Medium, 2));
            events.GPSAccuracyAndToleranceStateEvents.PutValueAtDate(referenceDate.AddMinutes(-56), new GPSAccuracyAndTolerance(GPSAccuracy.Coarse, 1));
            Assert.True(3 == events.GPSAccuracyAndToleranceStateEvents.Count(), $"List contains {events.GPSAccuracyAndToleranceStateEvents.Count()} GPSAccuracy events, instead of 3");

            var storageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Mutable);

            storageProxy.SetImmutableStorageProxy(new StorageProxy_Ignite_Transactional(StorageMutability.Immutable));
            events.SaveMachineEventsToPersistentStore(storageProxy);
        }