Beispiel #1
0
            public async Task Should_return_a_collection_of_students()
            {
                var            suppliedDatabaseContext = AsyncDatabaseContextMockingHelper.GetMockedStudentDatabaseContext();
                IPeopleService service     = new PeopleService(suppliedDatabaseContext.Object);
                var            actualModel = await service.Get(new QuerySpec()) as List <object>;

                Assert.IsTrue(actualModel.Any());
            }
Beispiel #2
0
            public async Task Should_update_student_info()
            {
                var            suppliedContext = AsyncDatabaseContextMockingHelper.GetMockedStudentDatabaseContext();
                IPeopleService service         = new PeopleService(suppliedContext.Object);

                // Get a student and update his name.
                var actualModel = await service.Get(1);

                actualModel.FirstName = "Johnathan";

                // Call the update method
                await service.Update(actualModel);

                // Get the model again to ensure it has been updated.
                var updatedModel = await service.Get(1);

                Assert.IsTrue(actualModel.FirstName == updatedModel.FirstName);
            }
Beispiel #3
0
            public async Task Should_return_a_the_student_with_the_requested_id()
            {
                var            suppliedContext   = AsyncDatabaseContextMockingHelper.GetMockedStudentDatabaseContext();
                IPeopleService service           = new PeopleService(suppliedContext.Object);
                var            suppliedStudentId = 1;
                var            actualModel       = await service.Get(suppliedStudentId);

                Assert.IsTrue(actualModel.Id == suppliedStudentId);
            }
 public ActionResult <List <People> > Get()
 {
     return(_peopleService.Get());
 }
Beispiel #5
0
 public void OnGet()
 {
     PeopleList = _service.Get().ToList();
 }
        public void GetPerson_ValidId_ReturnsCorrectObject()
        {
            //Arrange
            var expectedResult = new PersonDto
            {
                Name   = "Harry Potter",
                Id     = 3,
                Father = new PersonDto()
                {
                    Name = "James Potter",
                    Id   = 1
                },
                Mother = new PersonDto()
                {
                    Name = "Lily Potter",
                    Id   = 2
                },
                Place = new PlaceDto()
                {
                    Name = "Hogwarths",
                    Id   = 1
                }
            };

            _peopleRepo.Get(Arg.Is <int>(id => id == 1)).Returns(new Person
            {
                Name = "James Potter",
                Id   = 1
            });

            _peopleRepo.Get(Arg.Is <int>(id => id == 2)).Returns(new Person
            {
                Name = "Lily Potter",
                Id   = 2
            });

            _peopleRepo.Get(Arg.Is <int>(id => id == 3)).Returns(new Person
            {
                Name     = "Harry Potter",
                Id       = 3,
                FatherId = 1,
                MotherId = 2,
                PlaceId  = 1
            });

            _placeRepo.Get(Arg.Is <int>(id => id == 1)).Returns(new Place
            {
                Name = "Hogwarths",
                Id   = 1
            });

            //Act

            var result = _peopleService.Get(expectedResult.Id);

            //Assert

            Assert.True(result?.Name == expectedResult.Name);
            Assert.True(result?.Id == expectedResult.Id);

            Assert.True(result?.Father?.Name == expectedResult.Father.Name);
            Assert.True(result?.Mother?.Name == expectedResult.Mother.Name);
        }
Beispiel #7
0
 public ActionResult <List <Peoples> > Get() =>
 _peopleService.Get();
Beispiel #8
0
 public ActionResult Index()
 {
     return(View(peopleService.Get()));
 }