Exemplo n.º 1
0
        public void ShouldNotThrowWithValidVariable()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation().Add <string>("_value");

            //Act
            Action action = () => subject.AssertExpectedVariables(new VariabledClass());

            //Assert
            action.Should().NotThrow();
        }
Exemplo n.º 2
0
        public void ShouldThrowWithInvalidVariableType()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation().Add <Action>("_value");

            //Act
            Action action = () => subject.AssertExpectedVariables(new VariabledClass());

            //Assert
            action.Should().Throw <Exception>().WithMessage("Expected [name=_value] to be of [type=Action] but found [type=String]");
        }
Exemplo n.º 3
0
        public void ShouldNotThrowGivenMatchingPrimitive()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <string>("_value", "stringValue");
            VariabledClass target = new VariabledClass();

            //Act
            subject.AssertFieldsAreExpectedType(target);

            //Assert
        }
Exemplo n.º 4
0
        public void ShouldThrowWithInvalidVariableTypeInBaseClass()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <Action>("_value");

            //Act
            Action action = () => subject.AssertFieldsAreExpectedTypeInBaseClass <BaseClass>(new DerivedClass());

            //Assert
            action.Should().Throw <Exception>().WithMessage("Expected [name=_value] to be of [type=Action] but found [type=String]");
        }
Exemplo n.º 5
0
        public void ShouldNotThrowGivenEquatableObject()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <EquatableObject>("_eo", new EquatableObject("SomeValue"));

            //Act
            Action action = () => subject.AssertFieldsAreExpectedType(new EquatableObjectContainer(new EquatableObject("SomeValue")));

            //Assert
            action.Should().NotThrow();
        }
Exemplo n.º 6
0
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .Add <AddTimeIntervalAtFirstAccess>("_timeInstant");

            //Act
            NowAtFirstAccessUntil subject = new NowAtFirstAccessUntil(null);

            //Assert
            classVariableTypeValidation.AssertExpectedVariables(subject);
        }
Exemplo n.º 7
0
        public void ShouldNotThrowWithValidVariableInBaseClass()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <string>("_value");

            //Act
            Action action = () => subject.AssertFieldsAreExpectedTypeInBaseClass <BaseClass>(new DerivedClass());

            //Assert
            action.Should().NotThrow();
        }
Exemplo n.º 8
0
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .Add <ConsoleReaderBookEnd>("_reader");

            //Act
            ConsoleGameEnding subject = new ConsoleGameEnding();

            //Assert
            classVariableTypeValidation.AssertExpectedVariables(subject);
        }
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .Add <ValidResponse <IGameMode> >("_validResponse");

            //Act
            GameModeSelection subject = new GameModeSelection();

            //Assert
            classVariableTypeValidation.AssertExpectedVariables(subject);
        }
Exemplo n.º 10
0
        public void ShouldThrowWithInvalidVariableName()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <string>("_value2");

            //Act
            Action action = () => subject.AssertFieldsAreExpectedType(new VariabledClass());

            //Assert
            action.Should().Throw <Exception>().WithMessage("Expected field [name=_value2] to be of [type=string] but a field [name=_value2] was not found.");
        }
Exemplo n.º 11
0
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .Add <SemaphoreSlimBookEnd>("_semaphore")
                                                                      .Add <ClassCacheSync <string> >("_cache");

            //Act
            BlockingClassCacheSync <string> subject = new BlockingClassCacheSync <string>();

            //Assert
            classVariableTypeValidation.AssertExpectedVariables(subject);
        }
Exemplo n.º 12
0
        public void ShouldThrowGivenEquatableNonEqualObject()
        {
            //Arrange
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <EquatableObject>("_eo", new EquatableObject("SomeValue"));

            //Act
            Action action = () => subject.AssertFieldsAreExpectedType(new EquatableObjectContainer(new EquatableObject("OtherValue")));

            //Assert
            action.Should().Throw <AsserterException>().WithMessage(
                "Field [name=_eo] is not the same reference as expected and does not '#Equals()' actual. [expected=InterfaceMocksTests.Validators.ClassVariableTypeValidationTests+EquatableObject] [actual  =InterfaceMocksTests.Validators.ClassVariableTypeValidationTests+EquatableObject]");
        }
Exemplo n.º 13
0
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .Add <SessionTimerUpdateAction_TimerFinished>("_finished")
                                                                      .Add <CountdownTimerUpdateAction_TimerRunning>("_running");

            //Act
            SessionTimerUpdateAction subject = new SessionTimerUpdateAction();

            //Assert
            classVariableTypeValidation.AssertExpectedVariables(subject);
        }
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .FieldShouldBeType <MockMethodWithParam <string> >("_paramMethod")
                                                                      .FieldShouldBeType <MockMethodWithResponse <bool> >("_responseMethod");

            //Act
            MockMethodWithParamAndResponse <string, bool> subject
                = new MockMethodWithParamAndResponse <string, bool>("hah");

            //Assert
            classVariableTypeValidation.AssertFieldsAreExpectedType(subject);
        }
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .Add <CountdownTimerUpdateAction_ShowShortBreakStart>("_shortBreakAction")
                                                                      .Add <CountdownTimerUpdateAction_ShowLongBreakStart>("_longBreakAction")
                                                                      .Add <Counter>("_counter");

            //Act
            SessionTimerUpdateAction_ShowNextStart subject = new SessionTimerUpdateAction_ShowNextStart(null);

            //Assert
            classVariableTypeValidation.AssertExpectedVariables(subject);
        }
Exemplo n.º 16
0
        public void ShouldNotThrowGivenSameObject()
        {
            //Arrange
            VariabledClass expectedValue        = new VariabledClass();
            ExampleObject  exampleObject        = new ExampleObject(expectedValue);
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <VariabledClass>("_variable", expectedValue);

            //Act
            Action action = () => subject.AssertFieldsAreExpectedType(exampleObject);

            //Assert
            action.Should().NotThrow();
        }
Exemplo n.º 17
0
        public void ShouldThrowGivenDifferentObjects()
        {
            //Arrange
            ExampleObject exampleObject         = new ExampleObject(new VariabledClass());
            ClassVariableTypeValidation subject = new ClassVariableTypeValidation()
                                                  .FieldShouldBeType <VariabledClass>("_variable", new VariabledClass());

            //Act
            Action action = () => subject.AssertFieldsAreExpectedType(exampleObject);

            //Assert
            action.Should().Throw <AsserterException>().WithMessage(
                "Field [name=_variable] is not the same reference as expected and does not '#Equals()' actual. [expected=InterfaceMocksTests.Validators.ClassVariableTypeValidationTests+VariabledClass] [actual  =InterfaceMocksTests.Validators.ClassVariableTypeValidationTests+VariabledClass]");
        }
Exemplo n.º 18
0
        public void ShouldValidateTheVariables()
        {
            //Arrange
            ClassVariableTypeValidation classVariableTypeValidation = new ClassVariableTypeValidation()
                                                                      .Add <Board>("_board")
                                                                      .Add <ConsoleGameEnding>("_ending")
                                                                      .Add <GameModeSelection>("_gameModeSelection")
                                                                      .Add <ConsoleGameStarting>("_starting");

            //Act
            TicTacToeGame subject = new TicTacToeGame();

            //Assert
            classVariableTypeValidation.AssertExpectedVariables(subject);
        }