Esempio n. 1
0
        public async void GetOneLocationReturnsLocation()
        {
            //A -arrange
            var location1 = new Location();

            location1.ID   = 1;
            location1.Name = "Cici";
            var mockRepo = new Mock <ILocationRepository>();

            mockRepo.Setup(repo => repo.GetByIdAsync(It.IsAny <long>()))
            .Returns(Task.FromResult(location1));
            var controller = new LocationsController(mockRepo.Object);
            //A -act
            var result = await controller.GetOne(location1.ID);

            //A -assert
            var viewResult = Assert.IsType <Location>((result.Result as ObjectResult).Value);

            Assert.Equal(viewResult.Name, "Cici");
        }