예제 #1
0
        public void ThrowInvalidUnitCreationCommandException_WhenTheCommandIsNotValid(string command)
        {
            var factory = new UnitsFactory();

            Assert.Throws <InvalidUnitCreationCommandException>
                (() => factory.GetUnit(command));
        }
예제 #2
0
        public void GetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenInvalidUnitTypeCommandIsPassed()
        {
            // Arrange
            var createUnit = new UnitsFactory();

            Assert.Throws <InvalidUnitCreationCommandException>(() => createUnit.GetUnit("create unit Procyno Gosho 1"));
        }
예제 #3
0
        public void GetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenCommandParameterIsInvalid(string command)
        {
            var unitsFactory = new UnitsFactory();

            Assert.That(() => unitsFactory.GetUnit(command),
                        Throws.InstanceOf <InvalidUnitCreationCommandException>());
        }
예제 #4
0
        public void UnitsFactoryGetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenInvalidIdPassed()
        {
            // Arrange
            var uf = new UnitsFactory();

            // Act and Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => uf.GetUnit("create unit Lacaille Pesho ID"));
        }
예제 #5
0
        public void UnitsFactoryGetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenStringDoesNotContainsValidType()
        {
            // Arrange
            var uf = new UnitsFactory();

            // Act and Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => uf.GetUnit("create unit INVALID_TYPE Pesho 2"));
        }
        public void ThrowInvalidUnitCreationCommandException_WhenThePassedCommandIsInvalid(string command)
        {
            // Arrange
            var factory = new UnitsFactory();

            // Act & Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => factory.GetUnit(command));
        }
예제 #7
0
        public void ThrowInvalidUnitCreationCommandExceptionWhenPassedCommandIsNull()
        {
            //Arrange
            var sut = new UnitsFactory();

            //Act & Assert
            Assert.ThrowsException <InvalidUnitCreationCommandException>(() => sut.GetUnit(null));
        }
예제 #8
0
        public void ReturnCorrectUnitType_WhenValidCommandIsPassed(string command, Type type)
        {
            var factory = new UnitsFactory();

            var unit = factory.GetUnit(command);

            Assert.IsInstanceOf(type, unit);
        }
예제 #9
0
        public void GetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenNullCommandIsPassed()
        {
            // Arrange
            var createUnit = new UnitsFactory();

            // Act & Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => createUnit.GetUnit(null));
        }
예제 #10
0
        public void GetUnit_WhenCommandIsValid_ShouldReturnNewLuytenUnit()
        {
            var unitFactory = new UnitsFactory();

            var unit = unitFactory.GetUnit("create unit Luyten Pesho 2");

            Assert.IsInstanceOf <Luyten>(unit);
        }
예제 #11
0
        public void ThrowInvalidUnitCreationCommandExceptionWhenUnitTypeIsInvalid()
        {
            //Arrange
            var sut = new UnitsFactory();

            //Act & Assert
            Assert.ThrowsException <InvalidUnitCreationCommandException>(() => sut.GetUnit("create unit Invalid Pesho 1"));
        }
예제 #12
0
    void Start()
    {
        var unitsFactory = new UnitsFactory();

        unitsFactory.AddFactory(new MagFactory());
        unitsFactory.AddFactory(new InfantryFactory());
        List <IUnit> units2 = unitsFactory.ParseFile("file.json");
    }
예제 #13
0
        public void UnitsFactoryGetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenInvalidIdPassed()
        {
            // Arrange
            var uf = new UnitsFactory();

            // Act and Assert
            Assert.Throws<InvalidUnitCreationCommandException>(() => uf.GetUnit("create unit Lacaille Pesho ID"));
        }
예제 #14
0
        public void GetUnit_WhenAValidCorrespondingCommandIsPassed_ShoudCreateProcyon()
        {
            var factory = new UnitsFactory();

            var Unit = factory.GetUnit("create unit Procyon Gosho 1");

            Assert.IsInstanceOf <Procyon>(Unit);
        }
예제 #15
0
        public void TestGetUnit_PassValidLacailleCommand_ShouldInitialiseCorrectly(string command)
        {
            var factory = new UnitsFactory();

            var proycon = factory.GetUnit(command);

            Assert.IsInstanceOf <Lacaille>(proycon);
        }
예제 #16
0
        public void GetUnit_WhenCommandIsValid_ShouldReturnNewProcyonUnit()
        {
            var unitFactory = new UnitsFactory();

            var unit = unitFactory.GetUnit("create unit Procyon Gosho 1");

            Assert.IsInstanceOf <Procyon>(unit);
        }
예제 #17
0
        public void UnitsFactoryGetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenStringDoesNotContainsValidType()
        {
            // Arrange
            var uf = new UnitsFactory();

            // Act and Assert
            Assert.Throws<InvalidUnitCreationCommandException>(()=> uf.GetUnit("create unit INVALID_TYPE Pesho 2"));
        }
예제 #18
0
        public void ThrowInvalidUnitCreationCommandExceptionWhenUnitIDIsNotANumber()
        {
            //Arrange
            var sut = new UnitsFactory();

            //Act & Assert
            Assert.ThrowsException <InvalidUnitCreationCommandException>(() => sut.GetUnit("create unit Lacaille Pesho NotANumber"));
        }
예제 #19
0
        public void GetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenInvalidUnitIdCommandIsPassed()
        {
            // Arrange
            var createUnit = new UnitsFactory();

            // Act & Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => createUnit.GetUnit("create unit Procyon Gosho 165461854894651654986164894615"));
        }
예제 #20
0
        public void GetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenInvalidFormatCommandIsPassed()
        {
            // Arrange
            var createUnit = new UnitsFactory();

            // Act & Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => createUnit.GetUnit("Procyon Gosho 1 create unit"));
        }
예제 #21
0
        public void GetUnit_WhenTheCommandPassedIsNotInTheValidFormat_ShouldThrowInvalidUnitCreationCommandException(string invalidInput)
        {
            // Arrange
            var factory = new UnitsFactory();

            // Act &&  // Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => factory.GetUnit(invalidInput));
        }
예제 #22
0
        public void GetUnit_WhenAValidCorrespondingCommandIsPassed_ShoudCreateLacaillet()
        {
            var factory = new UnitsFactory();

            var Unit = factory.GetUnit("create unit Lacaille Tosho 3");

            Assert.IsInstanceOf <Lacaille>(Unit);
        }
예제 #23
0
        public void GetUnit_WhenAValidCorrespondingCommandIsPassed_ShoudCreateLuyten()
        {
            var factory = new UnitsFactory();

            var Unit = factory.GetUnit("create unit Luyten Pesho 2");

            Assert.IsInstanceOf <Luyten>(Unit);
        }
예제 #24
0
        //The following testcase doesn't throw an error, although command is invalid. Sadly we cannot edit the source code :(
        //[TestCase("Dreate unit Luyten Pesho 2")]
        public void GetUnit_WhenInvalidCommandIsPassed_ShouldThrowInvalidUnitCreationCommandException(string command)
        {
            //Arrange
            var factory = new UnitsFactory();

            //Act and assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => factory.GetUnit(command));
        }
예제 #25
0
        public void GetUnit_WhenCommandIsValid_ShouldReturnNewLacailleUnit()
        {
            var unitFactory = new UnitsFactory();

            var unit = unitFactory.GetUnit("create unit Lacaille Tosho 3");

            Assert.IsInstanceOf <Lacaille>(unit);
        }
예제 #26
0
        [TestCase("create unit Procyon Gosho one")] // test with passing invalid Id number
        public void GetUnit_ShouldThrowInvalidUnitCreationCommandException_WhenThePassedCommandIsNotInTheValidFormat(string command)
        {
            // Arrange
            string enteredCommand = command;
            var    unitFactory    = new UnitsFactory();

            // Act and Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => unitFactory.GetUnit(enteredCommand));
        }
예제 #27
0
        public void ThrowException_WhenInvalidParameterCountIsPassed()
        {
            // Arrange
            string       command      = "create Luyten Tosho 3";
            UnitsFactory unitsFactory = new UnitsFactory();

            // Act && Assert
            Assert.Throws <InvalidUnitCreationCommandException>(() => unitsFactory.GetUnit(command));
        }
예제 #28
0
        public void GetUnit_ShouldReturnANewLacailleUnit_WhenAValidMatchingCommandParatemerIsPassed()
        {
            var command      = "create unit Lacaille Gosho 1";
            var unitsFactory = new UnitsFactory();

            var actualUnit = unitsFactory.GetUnit(command);

            Assert.That(actualUnit, Is.Not.Null.And.InstanceOf <Lacaille>());
        }
예제 #29
0
        public void GetUnit_ShourReturnANewProcyonUnit_WhenAValidMatchingCommandParameterIsPassed()
        {
            var command      = "create unit Procyon Gosho 1";
            var unitsFactory = new UnitsFactory();

            var actualUnit = unitsFactory.GetUnit(command);

            Assert.That(actualUnit, Is.Not.Null.And.InstanceOf <Procyon>());
        }
예제 #30
0
        public void GetUnit_ShouldReturnLacaille_WhenValidCorrespondingCommandIsPassed()
        {
            var validCommand = "create unit Lacaille Tosho 3";

            var factory = new UnitsFactory();

            var result = factory.GetUnit(validCommand);

            Assert.IsInstanceOf <Lacaille>(result);
        }
예제 #31
0
        public void GetUnit_ShouldReturnLuyten_WhenValidCorrespondingCommandIsPassed()
        {
            var validCommand = "create unit Luyten Pesho 2";

            var factory = new UnitsFactory();

            var result = factory.GetUnit(validCommand);

            Assert.IsInstanceOf <Luyten>(result);
        }
예제 #32
0
        public void GetUnit_WhenValidCommandIsPassed_ShouldReturnCorrespondingUnit(string command, Type expectedType)
        {
            //Arrange
            var factory = new UnitsFactory();
            //Act
            var unit = factory.GetUnit(command);

            //Assert
            Assert.IsInstanceOf(expectedType, unit);
        }
예제 #33
0
        public void UnitsFactoryGetUnit_ShouldInstantiateCorrectInstance_WhenValuePassedIsCorrect(string command, Type type)
        {
            // Arrange
            var uf = new UnitsFactory();

            // Act
            var unit = uf.GetUnit(command);

            // Assert
            Assert.IsInstanceOf(type, unit);
        }