Inheritance: UnityEditor.AssetPostprocessor
        public override void Verify(ConstructorInfo constructorInfo)
        {
            if (constructorInfo == null)
            {
                throw new ArgumentNullException("constructorInfo");
            }

            var parameters     = constructorInfo.GetParameters();
            var customizations = GetFreezingCustomizations(parameters);
            var constructorInfoSpecimenBuilder =
                new Postprocessor(
                    new ConstructorInfoSpecimenBuilder(),
                    new AutoPropertiesCommand()
                    );

            using (new FixtureCustomizationsDisposable(Fixture))
            {
                Fixture.Customizations.Add(constructorInfoSpecimenBuilder);
                Fixture.Customize(
                    new CompositeCustomization(
                        GetFreezingCustomizations(constructorInfo.ReflectedType)));
                VerifyEqualReturnsTrue(constructorInfo, customizations);
                for (var i = 0; i < parameters.Length; ++i)
                {
                    VerifyEqualReturnsFalse(constructorInfo, parameters, customizations, i);
                }
            }
        }
Esempio n. 2
0
        public async Task Postprocessor_Go_Should_Kill_Bots_That_Have_Negative_Health_Left()
        {
            // Arrange
            var randomHelper  = new Mock <IRandomHelper>();
            var postprocessor = new Postprocessor(randomHelper.Object);
            var arena         = new ArenaDto {
                Width = 1, Height = 1
            };
            var bot = new BotDto {
                Id = Guid.NewGuid(), CurrentHealth = -1
            };
            var bots          = new List <BotDto>(new[] { bot });
            var context       = ProcessingContext.Build(arena, bots);
            var botProperties = BotProperties.Build(bot, arena, bots);

            botProperties.CurrentMove = PossibleMoves.Idling;
            context.AddBotProperties(bot.Id, botProperties);

            // Act
            await postprocessor.Go(context);

            // Assert
            context.Bots.Should().HaveCount(1);
            context.Bots.Should().ContainEquivalentOf(new BotDto
            {
                CurrentHealth = 0,
                Move          = PossibleMoves.Died
            }, c => c.Including(p => p.CurrentHealth)
                                                      .Including(p => p.Move));
        }
        public TokenizerProcessingDecorator(ITokenizer tokenizer, Preprocessor preprocessor, Postprocessor postprocessor)
        {
            this.tokenizer = tokenizer;

            this.preprocessor = preprocessor;
            this.postprocessor = postprocessor;
        }
Esempio n. 4
0
        public async Task Postprocessor_Go_Should_Ignore_Bots_That_Have_Zero_Stamina_Left()
        {
            // Arrange
            var randomHelper  = new Mock <IRandomHelper>();
            var postprocessor = new Postprocessor(randomHelper.Object);
            var arena         = new ArenaDto {
                Width = 3, Height = 3
            };
            var bot = new BotDto {
                Id = Guid.NewGuid(), X = 1, Y = 1, CurrentHealth = 1, CurrentStamina = 0
            };
            var bots          = new List <BotDto>(new[] { bot });
            var context       = ProcessingContext.Build(arena, bots);
            var botProperties = BotProperties.Build(bot, arena, bots);

            botProperties.CurrentMove = PossibleMoves.WalkForward;
            context.AddBotProperties(bot.Id, botProperties);

            // Act
            await postprocessor.Go(context);

            // Assert
            context.Bots.Should().HaveCount(1);
            context.Bots.Should().ContainEquivalentOf(new BotDto
            {
                X = 1,
                Y = 1,
                CurrentStamina = 0,
                Move           = PossibleMoves.Idling
            }, c => c.Including(p => p.X)
                                                      .Including(p => p.Y)
                                                      .Including(p => p.CurrentStamina)
                                                      .Including(p => p.Move));
        }
Esempio n. 5
0
        public void CombineExplictPropertyWithAutoProperties()
        {
            // Fixture setup
            var expectedText = "Fnaah";

            var specifiedCommand = new BindingCommand<DoublePropertyHolder<string, int>, string>(ph => ph.Property1, expectedText);
            var reservedProperty = new InverseRequestSpecification(specifiedCommand);

            var customizedBuilder = new Postprocessor<DoublePropertyHolder<string, int>>(
                new Postprocessor<DoublePropertyHolder<string, int>>(
                    new MethodInvoker(new ModestConstructorQuery()),
                    specifiedCommand),
                new AutoPropertiesCommand<DoublePropertyHolder<string, int>>(reservedProperty),
                new AnyTypeSpecification());

            var builder = new CompositeSpecimenBuilder(
                customizedBuilder,
                Scenario.CreateAutoPropertyBuilder());
            var container = new SpecimenContext(builder);
            // Exercise system
            var result = container.Resolve(typeof(DoublePropertyHolder<string, int>));
            // Verify outcome
            var actual = Assert.IsAssignableFrom<DoublePropertyHolder<string, int>>(result);
            Assert.Equal(expectedText, actual.Property1);
            Assert.Equal(1, actual.Property2);
            // Teardown
        }
Esempio n. 6
0
        public void CombineExplicitPropertyWithAutoProperties()
        {
            // Arrange
            var expectedText = "Fnaah";

            var specifiedCommand = new BindingCommand <DoublePropertyHolder <string, int>, string>(ph => ph.Property1, expectedText);
            var reservedProperty = new InverseRequestSpecification(specifiedCommand);

            var customizedBuilder = new Postprocessor(
                new Postprocessor(
                    new MethodInvoker(new ModestConstructorQuery()),
                    specifiedCommand),
                new AutoPropertiesCommand(reservedProperty),
                new AnyTypeSpecification());

            var builder = new CompositeSpecimenBuilder(
                customizedBuilder,
                Scenario.CreateAutoPropertyBuilder());
            var container = new SpecimenContext(builder);
            // Act
            var result = container.Resolve(typeof(DoublePropertyHolder <string, int>));
            // Assert
            var actual = Assert.IsAssignableFrom <DoublePropertyHolder <string, int> >(result);

            Assert.Equal(expectedText, actual.Property1);
            Assert.Equal(1, actual.Property2);
        }
        public TokenizerProcessingDecorator(ITokenizer tokenizer, Preprocessor preprocessor, Postprocessor postprocessor)
        {
            this.tokenizer = tokenizer;

            this.preprocessor  = preprocessor;
            this.postprocessor = postprocessor;
        }
Esempio n. 8
0
        public void CreateDoesNotInvokeActionWhenSpecificationIsFalse()
        {
            // Arrange
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new object()
            };

            var verified = false;
            var mock     = new DelegatingSpecimenCommand
            {
                OnExecute = (s, c) => verified = true
            };

            var spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => false
            };

            var sut = new Postprocessor <object>(builder, mock, spec);
            // Act
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();

            sut.Create(dummyRequest, dummyContainer);
            // Assert
            Assert.False(verified, "Mock invoked");
        }
Esempio n. 9
0
        public void CreateInvokesActionWithCreatedSpecimenOnSutWithCommand()
        {
            // Arrange
            var expectedSpecimen = new DateTime(2010, 4, 26);
            var builder          = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => expectedSpecimen
            };

            var expectedContext = new DelegatingSpecimenContext();

            var verified = false;
            var mock     = new DelegatingSpecimenCommand
            {
                OnExecute                       = (s, c) =>
                                       verified = expectedSpecimen.Equals(s) && c == expectedContext
            };

            var sut = new Postprocessor <DateTime>(builder, mock);
            // Act
            var dummyRequest = new object();

            sut.Create(dummyRequest, expectedContext);
            // Assert
            Assert.True(verified, "Mock verified");
        }
Esempio n. 10
0
    public async Task Postprocessor_Go_Should_Allow_A_Bot_To_Teleport_Onto_Another_Idling_Bot()
    {
        // Arrange
        var randomHelper  = new Mock <IRandomHelper>();
        var postprocessor = new Postprocessor(randomHelper.Object);
        var arena         = new ArenaDto(4, 1);
        var bot1          = new BotDto {
            Id = Guid.NewGuid(), X = 0, Y = 0, Orientation = PossibleOrientations.East, CurrentStamina = 15, CurrentHealth = 1
        };
        var bot2 = new BotDto {
            Id = Guid.NewGuid(), X = 3, Y = 0, Orientation = PossibleOrientations.West, CurrentStamina = 1, CurrentHealth = 1
        };
        var bots           = new List <BotDto>(new[] { bot1, bot2 });
        var context        = ProcessingContext.Build(arena, bots);
        var bot1Properties = BotProperties.Build(bot1, arena, bots);
        var bot2Properties = BotProperties.Build(bot2, arena, bots);

        bot1Properties.CurrentMove      = PossibleMoves.Teleport;
        bot1Properties.MoveDestinationX = 3;
        bot1Properties.MoveDestinationY = 0;
        bot2Properties.CurrentMove      = PossibleMoves.Idling;
        context.AddBotProperties(bot1.Id, bot1Properties);
        context.AddBotProperties(bot2.Id, bot2Properties);

        // Act
        await postprocessor.Go(context);

        // Assert
        context.Bots.Should().HaveCount(2);
        context.Bots.Should().ContainEquivalentOf(new BotDto
        {
            X              = 3,
            Y              = 0,
            FromX          = 0,
            FromY          = 0,
            Orientation    = PossibleOrientations.East,
            CurrentStamina = 15 - Constants.STAMINA_ON_TELEPORT,
            Move           = PossibleMoves.Teleport
        }, c => c
                                                  .Including(p => p.X)
                                                  .Including(p => p.Y)
                                                  .Including(p => p.FromX)
                                                  .Including(p => p.FromY)
                                                  .Including(p => p.Orientation)
                                                  .Including(p => p.CurrentStamina)
                                                  .Including(p => p.Move));
        context.Bots.Should().ContainEquivalentOf(new BotDto
        {
            X              = 0,
            Y              = 0,
            Orientation    = PossibleOrientations.West,
            CurrentStamina = 1,
            Move           = PossibleMoves.Idling
        }, c => c.Including(p => p.X)
                                                  .Including(p => p.Y)
                                                  .Including(p => p.Orientation)
                                                  .Including(p => p.CurrentStamina)
                                                  .Including(p => p.Move));
    }
Esempio n. 11
0
        public async Task Postprocessor_Go_Should_Execute_A_Teleport_Before_A_Regular_Move_And_Thus_Block_Other_Bots_In_Their_Path()
        {
            // Arrange
            var randomHelper  = new Mock <IRandomHelper>();
            var postprocessor = new Postprocessor(randomHelper.Object);
            var arena         = new ArenaDto {
                Width = 5, Height = 1
            };
            var bot1 = new BotDto {
                Id = Guid.NewGuid(), X = 0, Y = 0, Orientation = PossibleOrientations.East, CurrentStamina = 15, CurrentHealth = 1
            };
            var bot2 = new BotDto {
                Id = Guid.NewGuid(), X = 4, Y = 0, Orientation = PossibleOrientations.West, CurrentStamina = 1, CurrentHealth = 1
            };
            var bots           = new List <BotDto>(new[] { bot1, bot2 });
            var context        = ProcessingContext.Build(arena, bots);
            var bot1Properties = BotProperties.Build(bot1, arena, bots);
            var bot2Properties = BotProperties.Build(bot2, arena, bots);

            bot1Properties.CurrentMove      = PossibleMoves.Teleport;
            bot1Properties.MoveDestinationX = 3;
            bot1Properties.MoveDestinationY = 0;
            bot2Properties.CurrentMove      = PossibleMoves.WalkForward;
            context.AddBotProperties(bot1.Id, bot1Properties);
            context.AddBotProperties(bot2.Id, bot2Properties);

            // Act
            await postprocessor.Go(context);

            // Assert
            context.Bots.Should().HaveCount(2);
            context.Bots.Should().ContainEquivalentOf(new BotDto
            {
                X              = 3,
                Y              = 0,
                Orientation    = PossibleOrientations.East,
                CurrentStamina = 15 - Constants.STAMINA_ON_TELEPORT,
                Move           = PossibleMoves.Teleport
            }, c => c.Including(p => p.X)
                                                      .Including(p => p.Y)
                                                      .Including(p => p.Orientation)
                                                      .Including(p => p.CurrentStamina)
                                                      .Including(p => p.Move));
            context.Bots.Should().ContainEquivalentOf(new BotDto
            {
                X              = 4,
                Y              = 0,
                Orientation    = PossibleOrientations.West,
                CurrentStamina = 1,
                Move           = PossibleMoves.Idling
            }, c => c.Including(p => p.X)
                                                      .Including(p => p.Y)
                                                      .Including(p => p.Orientation)
                                                      .Including(p => p.CurrentStamina)
                                                      .Including(p => p.Move));
        }
 public void SutIsNode()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     // Exercise system
     var sut = new Postprocessor<Version>(dummyBuilder, dummyCommand);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilderNode>(sut);
     // Teardown
 }
Esempio n. 13
0
        public void SutIsPostProcessor()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            // Act
            var sut = new Postprocessor(dummyBuilder, dummyCommand);

            // Assert
            Assert.IsAssignableFrom <Postprocessor <object> >(sut);
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            var postprocessor = new Postprocessor();

            Console.WriteLine();
            Console.WriteLine("Restored paragraphs in the English text:");
            Console.WriteLine(postprocessor.RestoreText(EnText));
            Console.WriteLine();
            Console.WriteLine("Restored paragraphs in the Russian text:");
            Console.WriteLine(postprocessor.RestoreText(RuText));
        }
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     Action<object> dummyAction = s => { };
     // Exercise system
     var sut = new Postprocessor(dummyBuilder, dummyAction);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
Esempio n. 16
0
        public void SutIsNode()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            // Act
            var sut = new Postprocessor <Version>(dummyBuilder, dummyCommand);

            // Assert
            Assert.IsAssignableFrom <ISpecimenBuilderNode>(sut);
        }
Esempio n. 17
0
        public async Task Postprocessor_Go_Should_Not_Move_Two_Bots_That_Are_Facing_Each_Other()
        {
            // Arrange
            var randomHelper  = new Mock <IRandomHelper>();
            var postprocessor = new Postprocessor(randomHelper.Object);
            var arena         = new ArenaDto {
                Width = 4, Height = 1
            };
            var bot1 = new BotDto {
                Id = Guid.NewGuid(), X = 1, Y = 0, Orientation = PossibleOrientations.East, CurrentStamina = 3, CurrentHealth = 1
            };
            var bot2 = new BotDto {
                Id = Guid.NewGuid(), X = 2, Y = 0, Orientation = PossibleOrientations.West, CurrentStamina = 4, CurrentHealth = 1
            };
            var bots           = new List <BotDto>(new[] { bot1, bot2 });
            var context        = ProcessingContext.Build(arena, bots);
            var bot1Properties = BotProperties.Build(bot1, arena, bots);
            var bot2Properties = BotProperties.Build(bot2, arena, bots);

            bot1Properties.CurrentMove = PossibleMoves.WalkForward;
            bot2Properties.CurrentMove = PossibleMoves.WalkForward;
            context.AddBotProperties(bot1.Id, bot1Properties);
            context.AddBotProperties(bot2.Id, bot2Properties);

            // Act
            await postprocessor.Go(context);

            // Assert
            context.Bots.Should().HaveCount(2);
            context.Bots.Should().ContainEquivalentOf(new BotDto
            {
                X              = 1,
                Y              = 0,
                Orientation    = PossibleOrientations.East,
                CurrentStamina = 3,
                Move           = PossibleMoves.Idling
            }, c => c.Including(p => p.X)
                                                      .Including(p => p.Y)
                                                      .Including(p => p.Orientation)
                                                      .Including(p => p.CurrentStamina)
                                                      .Including(p => p.Move));
            context.Bots.Should().ContainEquivalentOf(new BotDto
            {
                X              = 2,
                Y              = 0,
                Orientation    = PossibleOrientations.West,
                CurrentStamina = 4,
                Move           = PossibleMoves.Idling
            }, c => c.Including(p => p.X)
                                                      .Including(p => p.Y)
                                                      .Including(p => p.Orientation)
                                                      .Including(p => p.CurrentStamina)
                                                      .Including(p => p.Move));
        }
Esempio n. 18
0
        public void SutYieldsInjectedBuilder()
        {
            // Arrange
            var expected     = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var sut          = new Postprocessor <object>(expected, dummyCommand);

            // Act
            // Assert
            Assert.Equal(expected, sut.Single());
            Assert.Equal(expected, ((System.Collections.IEnumerable)sut).Cast <object>().Single());
        }
        public void SutIsSpecimenBuilder()
        {
            // Fixture setup
            var             dummyBuilder = new DelegatingSpecimenBuilder();
            Action <string> dummyAction  = s => { };
            // Exercise system
            var sut = new Postprocessor <string>(dummyBuilder, dummyAction);

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
            // Teardown
        }
Esempio n. 20
0
        public void SutIsNode()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            // Exercise system
            var sut = new Postprocessor <Version>(dummyBuilder, dummyCommand);

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilderNode>(sut);
            // Teardown
        }
Esempio n. 21
0
        public void CommandIsCorrectWhenConstructedMinimallyNonGenerically()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingSpecimenCommand();

            var sut = new Postprocessor(dummyBuilder, expected);
            // Act
            var actual = sut.Command;

            // Assert
            Assert.Equal(expected, actual);
        }
        public void BuilderIsCorrect()
        {
            // Fixture setup
            var expectedBuilder = new DelegatingSpecimenBuilder();
            Action<object> dummyAction = s => { };

            var sut = new Postprocessor<object>(expectedBuilder, dummyAction);
            // Exercise system
            ISpecimenBuilder result = sut.Builder;
            // Verify outcome
            Assert.Equal(expectedBuilder, result);
            // Teardown
        }
Esempio n. 23
0
        private static void LoadAndTestModel(string modelFileName)
        {
            var postprocessor = new Postprocessor(modelFileName);

            Console.WriteLine($"Model restored from '{modelFileName}'");

            Console.WriteLine();
            Console.WriteLine("Restored English text:");
            Console.WriteLine(postprocessor.RestoreText(EnText));
            Console.WriteLine();
            Console.WriteLine("Restored Russian text:");
            Console.WriteLine(postprocessor.RestoreText(RuText));
        }
Esempio n. 24
0
        public void SpecificationIsCorrectWhenConstructedWithMinimalConstructor()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor <object>(dummyBuilder, dummyCommand);
            // Act
            var actual = sut.Specification;

            // Assert
            Assert.IsAssignableFrom <TrueRequestSpecification>(actual);
        }
Esempio n. 25
0
        public void ComposePreservesCommand()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingSpecimenCommand();
            var sut          = new Postprocessor <object>(dummyBuilder, expected);
            // Act
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Assert
            var pp = Assert.IsAssignableFrom <Postprocessor <object> >(actual);

            Assert.Equal(expected, pp.Command);
        }
Esempio n. 26
0
        public void BuilderIsCorrectWhenConstructedWithMinimalConstructor()
        {
            // Arrange
            var expected     = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor <object>(expected, dummyCommand);
            // Act
            var actual = sut.Builder;

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 27
0
        public void BuilderIsCorrect()
        {
            // Arrange
            var             expectedBuilder = new DelegatingSpecimenBuilder();
            Action <object> dummyAction     = s => { };

            var sut = new Postprocessor <object>(expectedBuilder, dummyAction);
            // Act
            ISpecimenBuilder result = sut.Builder;

            // Assert
            Assert.Equal(expectedBuilder, result);
        }
Esempio n. 28
0
        public void ComposePreservesAction()
        {
            // Arrange
            Action <Version, ISpecimenContext> expected = (x, y) => { };
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new Postprocessor <Version>(dummyBuilder, expected);
            // Act
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Assert
            var pp = Assert.IsAssignableFrom <Postprocessor <Version> >(actual);

            Assert.Equal(expected, pp.Action);
        }
Esempio n. 29
0
        public void CommandIsCorrect()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingSpecimenCommand();

            var sut = new Postprocessor <object>(dummyBuilder, expected);
            // Act
            ISpecimenCommand actual = sut.Command;

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 30
0
        public void ActionIsNotNullWhenConstructedWithMinimalConstructor()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor <object>(dummyBuilder, dummyCommand);
            // Act
            var actual = sut.Action;

            // Assert
            Assert.NotNull(actual);
        }
Esempio n. 31
0
        public void ActionIsCorrect()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            Action <object, ISpecimenContext> expectedAction = (s, c) => { };

            var sut = new Postprocessor <object>(dummyBuilder, expectedAction);
            // Act
            Action <object, ISpecimenContext> result = sut.Action;

            // Assert
            Assert.Equal(expectedAction, result);
        }
Esempio n. 32
0
        public void SutYieldsInjectedBuilder()
        {
            // Fixture setup
            var expected     = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var sut          = new Postprocessor <object>(expected, dummyCommand);

            // Exercise system
            // Verify outcome
            Assert.Equal(expected, sut.Single());
            Assert.Equal(expected, ((System.Collections.IEnumerable)sut).Cast <object>().Single());
            // Teardown
        }
Esempio n. 33
0
        public void ComposePreservesSpecification()
        {
            // Arrange
            var expected     = new DelegatingRequestSpecification();
            var dummyCommand = new DelegatingSpecimenCommand();
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new Postprocessor <Version>(dummyBuilder, dummyCommand, expected);
            // Act
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Assert
            var pp = Assert.IsAssignableFrom <Postprocessor <Version> >(actual);

            Assert.Equal(expected, pp.Specification);
        }
Esempio n. 34
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var sut          = new Postprocessor <object>(dummyBuilder, dummyCommand);
            // Act
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Assert
            var pp = Assert.IsAssignableFrom <Postprocessor <object> >(actual);

            Assert.Equal(expected, pp.Builder);
        }
Esempio n. 35
0
        public void SpecificationIsCorrectWhenConstructedWithMinimalConstructor()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor <object>(dummyBuilder, dummyCommand);
            // Exercise system
            var actual = sut.Specification;

            // Verify outcome
            Assert.IsAssignableFrom <TrueRequestSpecification>(actual);
            // Teardown
        }
        public RecognitionController()
        {
            //module initialization
            _dataProcessor = new DataProcessor();
            _gestureModule = new GestureModule(this);
            _segmentationModule = new SegmentationModule(this);
            _featureSelector = new FeatureSelector();
            _NLPModule = new NLPModule();
            _classifier = new Classifier();
            _postprocessor = new Postprocessor();

            //data transfer event
            m_dataProcessor.m_dataWarehouse.m_dataTransferEvent += m_gestureModule.OnDataTransfer;
            //data ready event
            m_dataProcessor.m_dataTransferEvent += m_segmentationModule.OnNewFrameDataReady;
            m_dataProcessor.m_dataTransferEvent += m_gestureModule.OnNewFrameDataReady;
            //console manager
            ConsoleManager.Show();
        }
 public void CreateReturnsCorrectResult()
 {
     // Fixture setup
     var expectedResult = new object();
     var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult };
     Action<object> dummyAction = s => { };
     var sut = new Postprocessor(builder, dummyAction);
     // Exercise system
     var dummyRequest = new object();
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(dummyRequest, dummyContainer);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void ActionIsCorrect()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            Action<object, ISpecimenContext> expectedAction = (s, c) => { };

            var sut = new Postprocessor<object>(dummyBuilder, expectedAction);
            // Exercise system
            Action<object, ISpecimenContext> result = sut.Action;
            // Verify outcome
            Assert.Equal(expectedAction, result);
            // Teardown
        }
 public void SutYieldsInjectedBuilder()
 {
     // Fixture setup
     var expected = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     var sut = new Postprocessor<object>(expected, dummyCommand);
     // Exercise system
     // Verify outcome
     Assert.Equal(expected, sut.Single());
     Assert.Equal(expected, ((System.Collections.IEnumerable)sut).Cast<object>().Single());
     // Teardown
 }
 public void ComposeReturnsCorrectResult()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     var sut = new Postprocessor<object>(dummyBuilder, dummyCommand);
     // Exercise system
     var expectedBuilders = new[]
     {
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder()
     };
     var actual = sut.Compose(expectedBuilders);
     // Verify outcome
     var pp = Assert.IsAssignableFrom<Postprocessor<object>>(actual);
     var composite = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(pp.Builder);
     Assert.True(expectedBuilders.SequenceEqual(composite));
     // Teardown
 }
 public void ComposeSingleItemReturnsCorrectResult()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     var sut = new Postprocessor<object>(dummyBuilder, dummyCommand);
     // Exercise system
     var expected = new DelegatingSpecimenBuilder();
     var actual = sut.Compose(new[] { expected });
     // Verify outcome
     var pp = Assert.IsAssignableFrom<Postprocessor<object>>(actual);
     Assert.Equal(expected, pp.Builder);
     // Teardown
 }
 public void ComposePreservesAction()
 {
     // Fixture setup
     Action<Version, ISpecimenContext> expected = (x, y) => { };
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var sut = new Postprocessor<Version>(dummyBuilder, expected);
     // Exercise system
     var actual = sut.Compose(new ISpecimenBuilder[0]);
     // Verify outcome
     var pp = Assert.IsAssignableFrom<Postprocessor<Version>>(actual);
     Assert.Equal(expected, pp.Action);
     // Teardown
 }
 public void ComposePreservesSpecification()
 {
     // Fixture setup
     var expected = new DelegatingRequestSpecification();
     var dummyCommand = new DelegatingSpecimenCommand();
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var sut = new Postprocessor<Version>(dummyBuilder, dummyCommand, expected);
     // Exercise system
     var actual = sut.Compose(new ISpecimenBuilder[0]);
     // Verify outcome
     var pp = Assert.IsAssignableFrom<Postprocessor<Version>>(actual);
     Assert.Equal(expected, pp.Specification);
     // Teardown
 }
        public void SpecificationIsCorrectWhenConstructedWithMinimalConstructor()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor<object>(dummyBuilder, dummyCommand);
            // Exercise system
            var actual = sut.Specification;
            // Verify outcome
            Assert.IsAssignableFrom<TrueRequestSpecification>(actual);
            // Teardown
        }
        public void CommandIsCorrect()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected = new DelegatingSpecimenCommand();

            var sut = new Postprocessor<object>(dummyBuilder, expected);
            // Exercise system
            ISpecimenCommand actual = sut.Command;
            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void ActionIsNotNullWhenConstructedWithFullConstructor()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var dummySpecification = new DelegatingRequestSpecification();

            var sut = new Postprocessor<object>(
                dummyBuilder,
                dummyCommand,
                dummySpecification);
            // Exercise system
            var actual = sut.Action;
            // Verify outcome
            Assert.NotNull(actual);
            // Teardown
        }
 public TokenizerProcessingDecorator(ITokenizer tokenizer, Postprocessor postprocessor)
     : this(tokenizer, new Preprocessor(), postprocessor)
 {
 }
        public void CreateInvokesActionWithCreatedSpecimenOnSutWithCommand()
        {
            // Fixture setup
            var expectedSpecimen = new DateTime(2010, 4, 26);
            var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen };

            var expectedContext = new DelegatingSpecimenContext();

            var verified = false;
            var mock = new DelegatingSpecimenCommand
            {
                OnExecute = (s, c) =>
                    verified = expectedSpecimen.Equals(s) && c == expectedContext
            };

            var sut = new Postprocessor<DateTime>(builder, mock);
            // Exercise system
            var dummyRequest = new object();
            sut.Create(dummyRequest, expectedContext);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
        public void CreateDoesNotInvokeActionWhenSpecificationIsFalse()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() };

            var verified = false;
            var mock = new DelegatingSpecimenCommand
            {
                OnExecute = (s, c) => verified = true
            };

            var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => false };

            var sut = new Postprocessor<object>(builder, mock, spec);
            // Exercise system
            var dummyRequest = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            sut.Create(dummyRequest, dummyContainer);
            // Verify outcome
            Assert.False(verified, "Mock invoked");
            // Teardown
        }
        public void CreateThrowsWhenBuilderReturnsIncompatibleTypeOnSutWithDoubleAction()
        {
            // Fixture setup
            var nonInt = "Anonymous variable";
            var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => nonInt };

            var dummyCommand = new DelegatingSpecimenCommand();
            var sut = new Postprocessor<int>(builder, dummyCommand);
            // Exercise system and verify outcome
            var dummyRequest = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            Assert.Throws<InvalidOperationException>(() => sut.Create(dummyRequest, dummyContainer));
            // Teardown
        }
        public void SpecificationIsCorrectWhenConstructedWithFullConstructor()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var expected = new DelegatingRequestSpecification();

            var sut = new Postprocessor<object>(
                dummyBuilder,
                dummyCommand,
                expected);
            // Exercise system
            var actual = sut.Specification;
            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void CreateInvokesActionWithCreatedSpecimen()
        {
            // Fixture setup
            var expectedSpecimen = new object();
            var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen };

            var verified = false;
            Action<object> mock = s => verified = s == expectedSpecimen;

            var sut = new Postprocessor(builder, mock);
            // Exercise system
            var dummyRequest = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            sut.Create(dummyRequest, dummyContainer);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
 public void CreateReturnsCorrectResultOnSutWithDoubleAction()
 {
     // Fixture setup
     var expectedResult = 1m;
     var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult };
     var dummyCommand = new DelegatingSpecimenCommand();
     var sut = new Postprocessor<decimal>(builder, dummyCommand);
     // Exercise system
     var dummyRequest = new object();
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(dummyRequest, dummyContainer);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void SpecificationIsCorrect()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            Action<object, ISpecimenContext> dummyAction = (s, c) => { };
            var expectedSpec = new DelegatingRequestSpecification();

            var sut = new Postprocessor<object>(dummyBuilder, dummyAction, expectedSpec);
            // Exercise system
            IRequestSpecification result = sut.Specification;
            // Verify outcome
            Assert.Equal(expectedSpec, result);
            // Teardown
        }
        public void CreateInvokesDecoratedBuilderWithCorrectParametersOnSutWithDoubleAction()
        {
            // Fixture setup
            var expectedRequest = new object();
            var expectedContainer = new DelegatingSpecimenContext();

            var verified = false;
            var builderMock = new DelegatingSpecimenBuilder { OnCreate = (r, c) => verified = r == expectedRequest && c == expectedContainer };

            var dummyCommand = new DelegatingSpecimenCommand();
            var sut = new Postprocessor<bool>(builderMock, dummyCommand);
            // Exercise system
            sut.Create(expectedRequest, expectedContainer);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
Esempio n. 56
0
        public void CreateAndAddProperyValues()
        {
            // Fixture setup
            var ctorInvoker = new MethodInvoker(new ModestConstructorQuery());
            var strCmd = new BindingCommand<DoublePropertyHolder<string, int>, string>(ph => ph.Property1);
            var intCmd = new BindingCommand<DoublePropertyHolder<string, int>, int>(ph => ph.Property2);
            var strPostprocessor = new Postprocessor<DoublePropertyHolder<string, int>>(ctorInvoker, strCmd);
            var intPostprocessor = new Postprocessor<DoublePropertyHolder<string, int>>(strPostprocessor, intCmd);

            var builder = new CompositeSpecimenBuilder(
                new FilteringSpecimenBuilder(intPostprocessor, new ExactTypeSpecification(typeof(DoublePropertyHolder<string, int>))),
                Scenario.CreateAutoPropertyBuilder());
            var container = new SpecimenContext(builder);
            // Exercise system
            var result = container.Resolve(typeof(DoublePropertyHolder<string, int>));
            // Verify outcome
            var actual = Assert.IsAssignableFrom<DoublePropertyHolder<string, int>>(result);
            Assert.False(string.IsNullOrEmpty(actual.Property1), "Property1");
            Assert.Equal(1, actual.Property2);
            // Teardown
        }
        public void CreateReturnsCorrectResultWhenBuilderReturnsNoSpecimen()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() };

            var dummyCommand = new DelegatingSpecimenCommand();
            var sut = new Postprocessor<int>(builder, dummyCommand);
            // Exercise system
            var dummyRequest = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            var result = sut.Create(dummyRequest, dummyContainer);
            // Verify outcome
            Assert.IsAssignableFrom<NoSpecimen>(result);
            // Teardown
        }
Esempio n. 58
0
        public void CommandIsCorrectWhenConstructedFullyNonGenerically()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected = new DelegatingSpecimenCommand();
            var dummySpecification = new DelegatingRequestSpecification();

            var sut = new Postprocessor(dummyBuilder, expected, dummySpecification);
            // Exercise system
            var actual = sut.Command;
            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void BuilderIsCorrectWhenConstructedWithMinimalConstructor()
        {
            // Fixture setup
            var expected = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor<object>(expected, dummyCommand);
            // Exercise system
            var actual = sut.Builder;
            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }