public async Task Multiple_And_Simple_State_Check_Should_Be_Prevent_Multiple_Checks()
        {
            var myStateEntities = new SimpleStateCheckerTestBase.MyStateEntity[]
            {
                new SimpleStateCheckerTestBase.MyStateEntity()
                {
                    CreationTime = DateTime.Parse("2022-01-01", CultureInfo.InvariantCulture)
                },

                new SimpleStateCheckerTestBase.MyStateEntity()
                {
                    CreationTime = DateTime.Parse("2020-01-01", CultureInfo.InvariantCulture),
                }
            };

            myStateEntities[0].AddSimpleStateChecker(new MySimpleBatchStateChecker());
            myStateEntities[1].AddSimpleStateChecker(new MySimpleStateChecker());

            var result = await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities);

            result.Count.ShouldBe(2);

            result[myStateEntities[0]].ShouldBeTrue();
            result[myStateEntities[1]].ShouldBeFalse();

            myStateEntities[0].CheckCount.ShouldBe(0);
            myStateEntities[0].GlobalCheckCount.ShouldBe(0);
            myStateEntities[0].MultipleCheckCount.ShouldBe(1);
            myStateEntities[0].MultipleGlobalCheckCount.ShouldBe(0);

            myStateEntities[1].CheckCount.ShouldBe(1);
            myStateEntities[1].GlobalCheckCount.ShouldBe(0);
            myStateEntities[1].MultipleCheckCount.ShouldBe(0);
            myStateEntities[1].MultipleGlobalCheckCount.ShouldBe(0);
        }
예제 #2
0
        public async Task Multiple_State_Check_Should_Be_Works()
        {
            var checker = new MySimpleBatchStateChecker();

            var myStateEntities = new MyStateEntity[]
            {
                new MyStateEntity()
                {
                    CreationTime         = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture),
                    LastModificationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture)
                },

                new MyStateEntity()
                {
                    CreationTime         = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture),
                    LastModificationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture)
                }
            };

            foreach (var myStateEntity in myStateEntities)
            {
                myStateEntity.AddSimpleStateChecker(checker);
            }

            (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities)).ShouldAllBe(x => x.Value);

            foreach (var myStateEntity in myStateEntities)
            {
                myStateEntity.CreationTime = DateTime.Parse("2001-01-01", CultureInfo.InvariantCulture);
            }

            (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntities)).ShouldAllBe(x => !x.Value);
        }
예제 #3
0
        public async Task Multiple_Global_State_Check_Should_Be_Works()
        {
            var myStateEntity = new MyStateEntity()
            {
                CreationTime = DateTime.Parse("2021-01-01", CultureInfo.InvariantCulture)
            };

            (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeFalse();

            myStateEntity.LastModificationTime = DateTime.Parse("2001-01-01", CultureInfo.InvariantCulture);

            (await SimpleStateCheckerManager.IsEnabledAsync(myStateEntity)).ShouldBeTrue();
        }