コード例 #1
0
        public void Insert3TimesShouldSortThem()
        {
            var dataProvider = new DataProviderMockFactory().Create();
            var timeStringConverter = new TimeStringConverterMockFactory().Create();
            var objectUnderTest = new ConfigProviderWrapper(dataProvider, timeStringConverter)
            {
                Now = new System.DateTime(2015, 09, 14, 09, 30, 01),
            };
            var methodName = "Insert3Times";
            var expected = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 14, 09, 33, 01),
                ServiceName = methodName,
            };
            var expectedLess1min = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 14, 09, 32, 01),
                ServiceName = methodName,
            };

            var expectedPlus24h = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 15, 09, 33, 01),
                ServiceName = methodName,
            };

            objectUnderTest.InsertExecutionTimes(new[] { expectedPlus24h, expectedLess1min, expected});

            var actual = objectUnderTest.ExecutionTimes.ElementAt(1);

            Assert.AreEqual(expected, actual, string.Format("Mismatched time: expected:{0}, actual:{1}", expected.ScheduledTime, actual.ScheduledTime));
        }
コード例 #2
0
        public void CheckResetServiceExecutionTimesStays()
        {
            var dataProvider = new DataProviderMockFactory().Create();
            var timeStringConverter = new TimeStringConverterMockFactory().Create();
            var serviceProviderExecutionDateTime = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 15, 09, 29, 01),
                ServiceName = "ServiceProvider.ResetServiceExecutionTimes",
            };
            var serviceExecutionDateTime = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 15, 09, 29, 01),
                ServiceName = "Service.WorkerMethod",
            };
            var expected = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 15, 09, 29, 01),
                ServiceName = "ConfigProvider.ResetServiceExecutionTimes",
            };
            var objectUnderTest = new ConfigProviderWrapper(dataProvider, timeStringConverter)
            {
                Now = new System.DateTime(2015, 09, 14, 09, 34, 01),
                ExecutionTimes = new List<ExecutionDateTime>(new[] { serviceProviderExecutionDateTime, serviceExecutionDateTime, expected }),
            };

            objectUnderTest.RemoveServiceExecutionTimes();

            var actual = objectUnderTest.ExecutionTimes.Single();

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
 public void CheckTotalNumberOfConfigResetTimes()
 {
     var dataProvider = new DataProviderMockFactory().Create();
     var timeStringConverter = new TimeStringConverterMockFactory().Create();
     var objectUnderTest = new ConfigProviderWrapper(dataProvider, timeStringConverter)
     {
         Now = new DateTime(2015, 9, 15, 9, 34, 0),
     };
     var actual = objectUnderTest.CreateResetServiceAndConfigExecutionTimes();
     Assert.AreEqual(177, actual.Count());
 }
コード例 #4
0
 public void CheckFirstConfigResetTimes()
 {
     var dataProvider = new DataProviderMockFactory().Create();
     var timeStringConverter = new TimeStringConverterMockFactory().Create();
     var objectUnderTest = new ConfigProviderWrapper(dataProvider, timeStringConverter)
     {
         Now = new DateTime(2015, 9, 15, 9, 34, 0),
     };
     var expected = new DateTime(2015, 9, 15, 9, 34, 0);
     var actual = objectUnderTest.CreateResetServiceAndConfigExecutionTimes().First();
     Assert.AreEqual(expected, actual.ScheduledTime);
 }
コード例 #5
0
        public void CheckServiceExecutionTimesRemoved()
        {
            var dataProvider = new DataProviderMockFactory().Create();
            var timeStringConverter = new TimeStringConverterMockFactory().Create();
            var serviceExecutionDateTime = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 15, 09, 29, 01),
                ServiceName = "ServiceProvider.ResetServiceExecutionTimes",
            };
            var objectUnderTest = new ConfigProviderWrapper(dataProvider, timeStringConverter)
            {
                Now = new System.DateTime(2015, 09, 14, 09, 34, 01),
                ExecutionTimes = new List<ExecutionDateTime>(new[] { serviceExecutionDateTime }),
            };

            objectUnderTest.RemoveServiceExecutionTimes();

            var actual = objectUnderTest.ExecutionTimes.Count;

            Assert.AreEqual(0, actual);
        }
コード例 #6
0
        public void Insert2IdenticalTimes()
        {
            var dataProvider = new DataProviderMockFactory().Create();
            var timeStringConverter = new TimeStringConverterMockFactory().Create();
            var objectUnderTest = new ConfigProviderWrapper(dataProvider, timeStringConverter);
            var expected = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 14, 09, 34, 01),
                ServiceName = "Insert2IdenticalTimes",
            };
            var unexpected = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 14, 09, 34, 01),
                ServiceName = "Insert2IdenticalTimes"
            };

            objectUnderTest.InsertExecutionTimes(new[] { expected, unexpected });

            var actual = objectUnderTest.ExecutionTimes.Where(x => x.ServiceName == expected.ServiceName).Single();

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
        public void Insert2SameTimesOneStopper()
        {
            var dataProvider = new DataProviderMockFactory().Create();
            var timeStringConverter = new TimeStringConverterMockFactory().Create();
            var objectUnderTest = new ConfigProviderWrapper(dataProvider, timeStringConverter);
            var expected = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 14, 09, 34, 01),
                ServiceName = "Insert2IdenticalTimes",
            };
            var expectedWithStop = new ExecutionDateTime()
            {
                ScheduledTime = new System.DateTime(2015, 09, 14, 09, 34, 01),
                ServiceName = "Insert2IdenticalTimes",
                IsStop = true,
            };

            objectUnderTest.InsertExecutionTimes(new[] { expected, expectedWithStop });

            var actual = objectUnderTest.ExecutionTimes.Where(x => x.ServiceName == expected.ServiceName).Single();

            Assert.AreEqual(expectedWithStop, actual, "Expected time with Stop flag missing");
        }