public async Task TestCase_ReadSingle(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 ); if (!String.IsNullOrEmpty(usrid)) { var control = new UserDetailsController(context, mockHttpContextAccessor.Object); var getrst = control.Get(usrid); Assert.NotNull(getrst); var getokrst = Assert.IsType <OkObjectResult>(getrst); var usrreadobj = Assert.IsAssignableFrom <UserDetail>(getokrst.Value); Assert.Equal(usrid, usrreadobj.UserID); } await context.DisposeAsync(); }
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 AlbumsController(context, mockHttpContextAccessor.Object); var getrst = control.Get(); Assert.NotNull(getrst); var getokrst = Assert.IsType <OkObjectResult>(getrst); var allalbums = Assert.IsAssignableFrom <IQueryable <Album> >(getokrst.Value); if (String.IsNullOrEmpty(usrid)) { Assert.Equal(1, allalbums.Count()); } else if (usrid == DataSetupUtility.UserA) { Assert.Equal(2, allalbums.Count()); } else if (usrid == DataSetupUtility.UserB) { Assert.Equal(2, allalbums.Count()); } await context.DisposeAsync(); }
public async Task TestCase_Read() { var context = fixture.GetCurrentDataContext(); this.fixture.InitTestData(context); var control = new StatisticsController(context); var getrst = control.Get(); Assert.NotNull(getrst); var getokrst = Assert.IsType <ObjectResult>(getrst); var statisinfo = Assert.IsType <StatisticsInfo>(getokrst.Value); await context.DisposeAsync(); }
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 AlbumPhotosController(context, mockHttpContextAccessor.Object); var rst = control.Get(); Assert.NotNull(rst); await context.DisposeAsync(); }