コード例 #1
0
ファイル: SpaceshipTests.cs プロジェクト: Drumev00/CSharp-OOP
        public void Test_Whether_AddMethod_Throws_Exception_When_Astronaut_Already_Exists()
        {
            spaceship.Add(this.astronaut);
            var anotherAstronaut = new Astronaut("Grisho", 45);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(anotherAstronaut));
        }
コード例 #2
0
        public void AddAStro_ShouldThrowExcCapacity()
        {
            Spaceship space = new Spaceship("pesho", 1);

            space.Add(new Astronaut("gosho", 25));
            Assert.Throws <InvalidOperationException>(() => space.Add(new Astronaut("pesho", 15)));
        }
コード例 #3
0
        public void TestAddThrowsWithExistingAstronaut()
        {
            Spaceship space1 = new Spaceship("Zero", 5);

            space1.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => space1.Add(astronaut));
        }
コード例 #4
0
        public void TestAddThrowsWithFullCapacity()
        {
            Spaceship space1 = new Spaceship("Zero", 1);

            space1.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => space1.Add(new Astronaut("Gosho", 50)));
        }
コード例 #5
0
        public void AddAstronaut_ThrowsException_WhenCapacityIsEcxeeded()
        {
            var spaceship = new Spaceship("aa", 1);

            spaceship.Add(new Astronaut("bb", 11.1));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("vv", 2.2)));
        }
コード例 #6
0
        public void ThrowsExceptionWhenAddNewAstronautAndSameNameAlreadyExists()
        {
            Spaceship spaceship = new Spaceship("Universe", 5);

            spaceship.Add(new Astronaut("Rus", 100));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("Rus", 44.5)), "Astronaut Rus is already in!");
        }
コード例 #7
0
        public void AddMethod_WithoutCapacity_Should_ThrowExcepiton()
        {
            var spaceship = new Spaceship("Name One", 1);

            spaceship.Add(new Astronaut("One", 10));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("Two", 10)));
        }
コード例 #8
0
        public void AddMethod_AlreadyExistAustorinauth_Should_ThrowExcepiton()
        {
            var spaceship = new Spaceship("Name One", 10);

            spaceship.Add(new Astronaut("One", 10));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("One", 10)));
        }
コード例 #9
0
        public void Test_AddExistingAstronaut_Throws()
        {
            var spaceship = new Spaceship("Apolo", 2);

            spaceship.Add(new Astronaut("Pesho", 100));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("Pesho", 100)));
        }
コード例 #10
0
        public void CheckCapacityForAstronautDuplicationException()
        {
            var spaceship = new Spaceship("zaza", 7);

            spaceship.Add(new Astronaut("gogo", 4));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("gogo", 5)));
        }
コード例 #11
0
        public void Test_AddWithFullCapacity_Throws()
        {
            var spaceship = new Spaceship("Apolo", 1);

            spaceship.Add(new Astronaut("Pesho", 100));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("Gosho", 100)));
        }
コード例 #12
0
        public void TestAddThrows()
        {
            spaceship.Add(astronaut);

            Astronaut secondAst = new Astronaut("Pesho", 20);

            Assert.Throws <InvalidOperationException>(() => this.spaceship.Add(secondAst));
        }
コード例 #13
0
ファイル: SpaceshipTests.cs プロジェクト: drapperr/CSharp-OOP
        public void AddMethodShouldThrowInvalidOperationExceptionIfSpaceshipContainsAstronautWithThisName()
        {
            Spaceship spaceship = new Spaceship("Test", 2);

            spaceship.Add(new Astronaut("Ivan", 40));

            Assert.Throws <InvalidOperationException>((() => spaceship.Add(new Astronaut("Ivan", 50))));
        }
コード例 #14
0
ファイル: SpaceshipTests.cs プロジェクト: drapperr/CSharp-OOP
        public void AddMethodShouldThrowInvalidOperationExceptionIfCapacityIsFull()
        {
            Spaceship spaceship = new Spaceship("Test", 1);

            spaceship.Add(new Astronaut("Ivan", 40));

            Assert.Throws <InvalidOperationException>((() => spaceship.Add(new Astronaut("Dimo", 50))));
        }
コード例 #15
0
        public void ThrowsExceptionWhenAddNewAstronautWhenCapacityIsFull()
        {
            Spaceship spaceship = new Spaceship("Universe", 1);

            spaceship.Add(new Astronaut("Rus", 45.5));

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(new Astronaut("Ivan", 33.3)), "Spaceship is full!");
        }
コード例 #16
0
        public void AddingAstrWorks()
        {
            Astronaut astronaut = new Astronaut("fin", 100);

            spaceship.Add(astronaut);

            Assert.AreEqual(1, spaceship.Count);
        }
コード例 #17
0
        public void AddAstro_ShouldThrowExcExistAstro()
        {
            Spaceship space = new Spaceship("pesho", 1);
            Astronaut astro = new Astronaut("gosho", 25);

            space.Add(astro);
            Assert.Throws <InvalidOperationException>(() => space.Add(astro));
        }
コード例 #18
0
        public void Add_Astronaut_Work_Correctly()
        {
            spaceship.Add(astronaut);
            spaceship.Add(astronaut2);

            var count = spaceship.Count;

            Assert.AreEqual(2, count);
        }
コード例 #19
0
        public void AddingExistindAstronautShouldThrowException()
        {
            Spaceship spaceship = new Spaceship("Millennium falcon", 4);

            spaceship.Add(astronaut);
            spaceship.Add(astronaut1);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(astronaut));
        }
コード例 #20
0
        public void TestAddingExistingAstronaut()
        {
            Spaceship spaceship = new Spaceship("Enterprise", 50);
            Astronaut astronaut = new Astronaut("Neil", 100);

            spaceship.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(astronaut), $"Astronaut {astronaut.Name} is already in!");
        }
コード例 #21
0
        public void ExistingAstronaut()
        {
            Astronaut astronaut1 = new Astronaut("Pesho", 1);

            spaceship = new Spaceship("Moon", 2);
            spaceship.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(astronaut1), $"Astronaut {astronaut1.Name} is already in!");
        }
コード例 #22
0
 public void TestCount_And_AddRemoveWithValidData()
 {
     Assert.AreEqual(0, s.Count);
     s.Add(a);
     s.Add(ast);
     Assert.AreEqual(2, s.Count);
     s.Remove("Desen");
     Assert.AreEqual(1, s.Count);
 }
コード例 #23
0
        public void FullSpaceshipAdd()
        {
            Astronaut astronaut1 = new Astronaut("Name", 1);

            spaceship = new Spaceship("Moon", 1);
            spaceship.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(astronaut1), "Spaceship is full!");
        }
コード例 #24
0
        public void AddAstronaut_ThrowsException_WhenAddingSameAstronaut()
        {
            var spaceship = new Spaceship("aa", 1);
            var astronaut = new Astronaut("bb", 11.1);

            spaceship.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(astronaut));
        }
コード例 #25
0
        public void AddAstronautWhoIsAlredyInSpaceship()
        {
            Spaceship spaceship = new Spaceship("Hi", 3);

            Astronaut astronaut1 = new Astronaut("Gosho", 25);

            spaceship.Add(astronaut1);

            Assert.That(() => spaceship.Add(astronaut1), Throws.InvalidOperationException.With.Message.EqualTo($"Astronaut {astronaut1.Name} is already in!"));
        }
コード例 #26
0
        public void TestAddingWithFullCapacity()
        {
            Spaceship spaceship    = new Spaceship("Enterprise", 1);
            Astronaut astronaut    = new Astronaut("Neil", 100);
            Astronaut newAstronaut = new Astronaut("Armstrong", 100);

            spaceship.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(newAstronaut), "Spaceship is full!");
        }
コード例 #27
0
        public void AddAstronautShouldThrowExceptionWithExistingAstronautName()
        {
            Astronaut astronaut    = new Astronaut("TestName", 21.92);
            Spaceship spaceship    = new Spaceship("Test1", 40);
            Astronaut newAstronaut = new Astronaut("TestName", 22);

            spaceship.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(newAstronaut));
        }
コード例 #28
0
        public void GetSpaceshipCountShouldBeCorrect()
        {
            string    name = "Pesho";
            double    oxygenInPercentage = 20d;
            Astronaut astronaut          = new Astronaut(name, oxygenInPercentage);

            spaceship.Add(astronaut);

            Assert.AreEqual(1, spaceship.Count);
        }
コード例 #29
0
        public void CheckRemove()
        {
            var spaceship = new Spaceship("zaza", 7);

            spaceship.Add(new Astronaut("gogo", 4));
            spaceship.Add(new Astronaut("pipi", 4));

            var result = spaceship.Remove("gogo");

            Assert.AreEqual(true, result);
        }
コード例 #30
0
        public void AddingWhenFull()
        {
            spaceship = new Spaceship("Falc", 1);

            Astronaut astronaut  = new Astronaut("fin", 100);
            Astronaut astronaut1 = new Astronaut("min", 102);

            spaceship.Add(astronaut);

            Assert.Throws <InvalidOperationException>(() => spaceship.Add(astronaut1));
        }