public void Get_CalledWithNoArgument_ReturnsListOf3PhotoDatas() { //Arrange var expectedCount = 3; //Act var result = target.Get(); var count = result.ToList().Count; //Assert Assert.AreEqual(expectedCount, count, "Return record count"); }
public async Task WhenGetByIdIsCalledAPhotoMustBeReturned() { var photoId = "1234"; var photoStoreMock = new Mock <Domain.IPhotoStore>(); photoStoreMock.Setup(m => m.GetPhotoDetailsAsync(photoId)).Returns( Task.FromResult <Domain.IPhotoMetadata>(new Models.PhotoMetadata { Id = photoId, Title = "Hi" })); var sut = new PhotosController(photoStoreMock.Object); //sut.ControllerContext.HttpContext = ; var response = await sut.Get(photoId); Assert.IsType <ActionResult <Domain.IPhotoMetadata> >(response); Assert.NotNull(response.Result); Assert.IsType <OkObjectResult>(response.Result); var statusCode = ((OkObjectResult)response.Result).StatusCode; var value = ((OkObjectResult)response.Result).Value as Domain.IPhotoMetadata; Assert.Equal(statusCode, (int)System.Net.HttpStatusCode.OK); Assert.NotNull(value); Assert.True(string.Equals(value.Id, photoId, System.StringComparison.InvariantCultureIgnoreCase)); Assert.True(string.Equals(value.Title, "Hi", System.StringComparison.InvariantCultureIgnoreCase)); }
public void PhotosGet() { PhotosController photosController = new PhotosController(); Photos photos = photosController.Get(3); Assert.AreEqual(photos.Id, 3); }
public void PhotosGetAll() { PhotosController photosController = new PhotosController(); List <Photos> photos = photosController.Get(); int first = photos[0].Id; Assert.AreEqual(first, 3); }
public async Task TestCase_ReadList(String usrid) { var context = fixture.GetCurrentDataContext(); this.fixture.InitTestData(context); var mockHttpContextAccessor = new Mock <IHttpContextAccessor>(); mockHttpContextAccessor.Setup(req => req.HttpContext.User.Identity.Name).Returns( //It.IsAny<string>(usrid) usrid ); var control = new PhotosController(context, mockHttpContextAccessor.Object); var rst = control.Get(); Assert.NotNull(rst); await context.DisposeAsync(); }
public void GetOkResultt() { var result = _controller.Get(); Assert.IsType <OkObjectResult>(result.Result); }