Пример #1
0
        public void EventsTest()
        {
            Calendar target = new Calendar();

            Event callArrive = new CallArriveEvent(null, DateTime.Now.AddMinutes(10));

            target.AddEvent(callArrive);
            Event switchComp = new SwitchCompletedEvent(null, DateTime.Now.AddMinutes(5));

            target.AddEvent(switchComp);
            Event serviceComp = new CompletedServiceEvent(null, DateTime.Now.AddMinutes(20));

            target.AddEvent(serviceComp);
            Event endRep = new EndReplicationEvent(DateTime.Now.AddMinutes(30));

            target.AddEvent(endRep);

            List <Event> expected = new List <Event> {
                switchComp, callArrive, serviceComp, endRep
            };

            List <Event> actual;

            actual = target.Events;
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Пример #2
0
        public void CreateProcessArgsForTestCompleteService()
        {
            DateTime           beginTime             = DateTime.Now;
            TimeSpan           runningTime           = new TimeSpan(2, 0, 0);
            double             callArriveMultiplier  = 0.1;
            double             switchDelayMultiplier = 0.1;
            List <ProductType> productTypes          = new List <ProductType> {
                new ProductType("Test", 0.1, 0.1)
            };
            int      maxQueueLength                = 10;
            bool     singleQueueLength             = true;
            TimeSpan excessiveWaitTime             = new TimeSpan(0, 1, 0);
            Dictionary <SalesRepType, int> repNums = new Dictionary <SalesRepType, int>();

            repNums.Add(new SalesRepType("Test"), 2);
            Simulator sim = new Simulator(beginTime, runningTime, callArriveMultiplier, switchDelayMultiplier, productTypes, maxQueueLength, singleQueueLength, excessiveWaitTime, repNums);
            ProcessArgsFactory_Accessor target = new ProcessArgsFactory_Accessor(sim);

            Event e = new CompletedServiceEvent(null, DateTime.Now);

            EventProcessArgs actual;

            actual = target.CreateProcessArgsFor(e);
            Assert.IsInstanceOfType(actual, typeof(CompletedServiceProcessArgs));
        }
Пример #3
0
        public void CompletedServiceEventConstructorTest()
        {
            Call     entity              = null;
            DateTime eventTime           = new DateTime();
            CompletedServiceEvent target = new CompletedServiceEvent(entity, eventTime);

            Assert.IsInstanceOfType(target, typeof(CompletedServiceEvent));
        }
Пример #4
0
        public void RemoveEventTestMultipleItems()
        {
            Calendar target     = new Calendar();
            Event    callArrive = new CallArriveEvent(null, DateTime.Now.AddMinutes(10));

            target.AddEvent(callArrive);
            Event switchComp = new SwitchCompletedEvent(null, DateTime.Now.AddMinutes(5));

            target.AddEvent(switchComp);
            Event serviceComp = new CompletedServiceEvent(null, DateTime.Now.AddMinutes(20));

            target.AddEvent(serviceComp);
            Event endRep = new EndReplicationEvent(DateTime.Now.AddMinutes(30));

            target.AddEvent(endRep);
            target.RemoveEvent(callArrive);
            Assert.AreEqual(3, target.Events.Count);
        }
Пример #5
0
        public void NextEventOfTypeTestWithInvalidEnumReturnsNull()
        {
            Calendar target     = new Calendar();
            Event    callArrive = new CallArriveEvent(null, DateTime.Now.AddMinutes(10));

            target.AddEvent(callArrive);
            Event switchComp  = new SwitchCompletedEvent(null, DateTime.Now.AddMinutes(5));
            Event serviceComp = new CompletedServiceEvent(null, DateTime.Now.AddMinutes(20));

            target.AddEvent(serviceComp);
            Event endRep = new EndReplicationEvent(DateTime.Now.AddMinutes(30));

            target.AddEvent(endRep);

            Event actual;

            actual = target.NextEventOfType((EEventType)10);
            Assert.IsNull(actual);
        }
Пример #6
0
        public void NextEventOfTypeTestWithItemMatchEndReplication()
        {
            Calendar target     = new Calendar();
            Event    callArrive = new CallArriveEvent(null, DateTime.Now.AddMinutes(10));

            target.AddEvent(callArrive);
            Event switchComp = new SwitchCompletedEvent(null, DateTime.Now.AddMinutes(5));

            target.AddEvent(switchComp);
            Event serviceComp = new CompletedServiceEvent(null, DateTime.Now.AddMinutes(20));

            target.AddEvent(serviceComp);
            Event endRep = new EndReplicationEvent(DateTime.Now.AddMinutes(30));

            target.AddEvent(endRep);

            Event actual;

            actual = target.NextEventOfType(EEventType.EndReplication);
            Assert.AreEqual(endRep, actual);
        }