Beispiel #1
0
        public void Name_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"
            });
            controller.Add(new AddRecordRequestModel
            {
                data = "Jones Other Female Green 3/30/1979"
            });

            var output = controller.GetByName();

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

            Assert.IsNotNull(result);
            Assert.AreEqual(6, result.Content.Count());

            //expected order:
            //Some Dude
            //Meagan Hoschek
            //Norah Jones
            //Other Jones
            //Michael Jordan
            //Vamsi Nadimpalli

            Assert.AreEqual("Some", result.Content.ElementAt(0).FirstName);
            Assert.AreEqual("Meagan", result.Content.ElementAt(1).FirstName);
            Assert.AreEqual("Norah", result.Content.ElementAt(2).FirstName);
            Assert.AreEqual("Other", result.Content.ElementAt(3).FirstName);
            Assert.AreEqual("Michael", result.Content.ElementAt(4).FirstName);
            Assert.AreEqual("Vamsi", result.Content.ElementAt(5).FirstName);
        }
Beispiel #2
0
        public void TestNameFalse()
        {
            var test = new RecordsController();

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

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

            int expectedStatus = 204;

            Assert.AreEqual(status, expectedStatus);
        }
Beispiel #3
0
        public void TestNameTrue()
        {
            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.GetByName();

            Assert.IsNotNull(actionResult);
        }
        public void GetByNameTest()
        {
            //Arrange


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

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

            Assert.Equal(2, people.Count);
            Assert.Equal("Lovelace", people[0].LastName);
        }
Beispiel #5
0
        public void AssertScenarioGetByLastName()
        {
            // Setup Test
            RecordsController controller            = new RecordsController();
            const int         expectedRecordCount   = 6;
            const string      expectedLastNameOne   = "Bates";
            const string      expectedLastNameTwo   = "Green";
            const string      expectedLastNameThree = "Green";
            const string      expectedLastNameFour  = "Groates";
            const string      expectedLastNameFive  = "Rose";
            const string      expectedLastNameSix   = "Taylor";

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

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

            Person recordOne = result.ElementAt(0);

            Assert.AreEqual(expectedLastNameOne, recordOne.LastName);
            Person recordTwo = result.ElementAt(1);

            Assert.AreEqual(expectedLastNameTwo, recordTwo.LastName);
            Person recordThree = result.ElementAt(2);

            Assert.AreEqual(expectedLastNameThree, recordThree.LastName);
            Person recordFour = result.ElementAt(3);

            Assert.AreEqual(expectedLastNameFour, recordFour.LastName);
            Person recordFive = result.ElementAt(4);

            Assert.AreEqual(expectedLastNameFive, recordFive.LastName);
            Person recordSix = result.ElementAt(5);

            Assert.AreEqual(expectedLastNameSix, recordSix.LastName);
        }