示例#1
0
        public AirportOperation ChangeName(string airportName)
        {
            AirportOperation result = ValidationRules.AirportName(airportName);

            switch (result)
            {
            case AirportOperation.Succeded:
                _name = airportName;
                break;

            case AirportOperation.InvalidNameLenghtFailure:
                Console.WriteLine("Error: Airport name should be exact 3 letters long.");
                break;

            case AirportOperation.InvalidNameNullFailure:
                Console.WriteLine("Error: Airport name can not be null.");
                break;

            case AirportOperation.InvalidNameFormatFailure:
                Console.WriteLine("Error: Airport name should contain only capital letters.");
                break;
            }

            return(result);
        }
        public void NamePropertySetter_ThreeLetterStringWithSmallLettersName_ShouldPassTest()
        {
            // Arrange
            Airport          airport  = new Airport("ASD");
            AirportOperation expected = AirportOperation.InvalidNameFormatFailure;

            // Act
            AirportOperation actual = airport.ChangeName("asd");

            // Assert
            Assert.Equal(expected, actual);
        }
        public void NamePropertySetter_EmptyStringName_ShouldPassTest()
        {
            // Arrange
            Airport          airport  = new Airport("OFK");
            AirportOperation expected = AirportOperation.InvalidNameLenghtFailure;

            // Act
            AirportOperation actual = airport.ChangeName("");

            // Assert
            Assert.Equal(expected, actual);
        }
        public void NamePropertySetter_ShorterThanThreeLettersName_ShouldPassTest()
        {
            // Arrange
            Airport          airport  = new Airport("ASD");
            AirportOperation expected = AirportOperation.InvalidNameLenghtFailure;

            // Act
            AirportOperation actual = airport.ChangeName("AA");

            // Assert
            Assert.Equal(expected, actual);
        }
        public void NamePropertySetter_NullStringName_ShouldPassTest()
        {
            // Arrange
            string           nullString = null;
            Airport          airport    = new Airport("ASD");
            AirportOperation expected   = AirportOperation.InvalidNameNullFailure;

            // Act
            AirportOperation actual = airport.ChangeName(nullString);

            // Assert
            Assert.Equal(expected, actual);
        }