public void ThrowInvalidUnitCreationCommandException_WhenTheCommandIsNotValid(string command)
        {
            var factory = new UnitsFactory();

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

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

            Assert.That(() => unitsFactory.GetUnit(command),
                        Throws.InstanceOf <InvalidUnitCreationCommandException>());
        }
Example #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"));
        }
Example #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));
        }
Example #7
0
        public void ThrowInvalidUnitCreationCommandExceptionWhenPassedCommandIsNull()
        {
            //Arrange
            var sut = new UnitsFactory();

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

            var unit = factory.GetUnit(command);

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

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

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

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

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

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

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

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

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

            var proycon = factory.GetUnit(command);

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

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

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

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

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

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

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

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

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

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

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

            Assert.IsInstanceOf <Luyten>(Unit);
        }
Example #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));
        }
Example #25
0
        public void GetUnit_WhenCommandIsValid_ShouldReturnNewLacailleUnit()
        {
            var unitFactory = new UnitsFactory();

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

            Assert.IsInstanceOf <Lacaille>(unit);
        }
Example #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));
        }
Example #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));
        }
Example #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>());
        }
Example #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>());
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
        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);
        }