Ejemplo n.º 1
0
        public void AssertScenarioGetByGender()
        {
            // Setup TEst
            RecordsController controller           = new RecordsController();
            const int         expectedRecordCount  = 6;
            const string      expectedGenderFeMale = "F";
            const string      expectedGenderMale   = "M";

            // Act
            List <Person> result = controller.GetByGender();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expectedRecordCount, result.Count());

            Person recordOne = result.ElementAt(0);

            Assert.AreEqual(expectedGenderFeMale, recordOne.Gender);
            Person recordTwo = result.ElementAt(1);

            Assert.AreEqual(expectedGenderFeMale, recordTwo.Gender);
            Person recordThree = result.ElementAt(2);

            Assert.AreEqual(expectedGenderFeMale, recordThree.Gender);
            Person recordFour = result.ElementAt(3);

            Assert.AreEqual(expectedGenderMale, recordFour.Gender);
            Person recordFive = result.ElementAt(4);

            Assert.AreEqual(expectedGenderMale, recordFive.Gender);
            Person recordSix = result.ElementAt(5);

            Assert.AreEqual(expectedGenderMale, recordSix.Gender);
        }
Ejemplo n.º 2
0
        public void AssertScenarioPostNewPerson()
        {
            // Setup Test
            RecordsController controller          = new RecordsController();
            const int         expectedRecordCount = 7;

            Person personToAdd = new Person
            {
                FirstName     = "TestFirst",
                LastName      = "TestLast",
                Gender        = "F",
                BirthDate     = Convert.ToDateTime("1/1/2000"),
                FavoriteColor = "Infrared"
            };

            // Act
            controller.Post(personToAdd);

            // Get the people
            List <Person> result = controller.GetByGender();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expectedRecordCount, result.Count());
        }
Ejemplo n.º 3
0
        public void TestGenderTrue()
        {
            var test = new RecordsController();

            test.Delete(); //Make sure there is nothing in the datasource.
            test.RawStringFormatter("Testing,Orlando,Male,Grey,05/01/1982");
            test.RawStringFormatter("Testing,Monica,Female,Turquoise,05/12/1989");
            test.RawStringFormatter("Testing,Orlando,Male,Grey,05/01/1982");
            ActionResult <String> actionResult = test.GetByGender();

            Assert.IsNotNull(actionResult);
        }
Ejemplo n.º 4
0
        public void TestGenderFalse()
        {
            var test = new RecordsController();

            test.Delete(); //Make sure there is nothing in the datasource.
            ActionResult <String> actionResult = test.GetByGender();

            var status = (actionResult.Result as StatusCodeResult).StatusCode;

            int expectedStatus = 204;

            Assert.AreEqual(status, expectedStatus);
        }
        public void GetByGenderTest()
        {
            //Arrange


            //Act
            var result = _controller.GetByGender();

            //Assert
            var reponse = Assert.IsType <OkObjectResult>(result);
            var people  = Assert.IsType <List <Person> >(reponse.Value);

            Assert.Equal(2, people.Count);
            Assert.Equal("Female", people[0].Gender);
        }
Ejemplo n.º 6
0
        public void Gender_SuccessfulSort()
        {
            var controller = new RecordsController();

            controller.Add(new AddRecordRequestModel
            {
                data = "Nadimpalli Vamsi Male Blue 6/2/1983"
            });
            controller.Add(new AddRecordRequestModel
            {
                data = "Hoschek Meagan Female Pink 08/07/1985"
            });
            controller.Add(new AddRecordRequestModel
            {
                data = "Dude Some Male Black 1/1/1971"
            });
            controller.Add(new AddRecordRequestModel
            {
                data = "Jordan Michael Male Red 2/17/1963"
            });
            controller.Add(new AddRecordRequestModel
            {
                data = "Jones Norah Female Green 3/30/1979"
            });

            var output = controller.GetByGender();

            var result =
                output as
                System.Web.Http.Results.OkNegotiatedContentResult
                <IOrderedEnumerable <Person> >;

            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.Content.Count());
            Assert.AreEqual(Gender.Female, result.Content.ElementAt(0).Gender);
            Assert.AreEqual(Gender.Female, result.Content.ElementAt(1).Gender);
            Assert.AreEqual(Gender.Male, result.Content.ElementAt(2).Gender);
            Assert.AreEqual(Gender.Male, result.Content.ElementAt(3).Gender);
            Assert.AreEqual(Gender.Male, result.Content.ElementAt(4).Gender);
        }