public async Task GetByIdAsync_WithNonExistentId_ShouldReturnNull() { var context = BookStoreDbContextInMemoryFactory.InitializeContext(); await SeedData(context); this.categoryService = new AdminCategoryService(context); AdminCategoryListingServiceModel actualData = await this.categoryService.GetByIdAsync(-1); Assert.True(actualData == null); }
public async Task GetByIdAsync_WithExistentId_ShouldReturnCorrectResult() { var context = BookStoreDbContextInMemoryFactory.InitializeContext(); await SeedData(context); this.categoryService = new AdminCategoryService(context); AdminCategoryListingServiceModel expectedData = context.Categories.First().To <AdminCategoryListingServiceModel>(); AdminCategoryListingServiceModel actualData = await this.categoryService.GetByIdAsync(expectedData.Id); Assert.True(expectedData.Id == actualData.Id, "Id is not returned properly."); Assert.True(expectedData.Name == actualData.Name, "Name is not returned properly."); }
public async Task EditAsync_ShouldEditCategory() { var context = BookStoreDbContextInMemoryFactory.InitializeContext(); await SeedData(context); this.categoryService = new AdminCategoryService(context); AdminCategoryListingServiceModel expectedData = context.Categories.First().To <AdminCategoryListingServiceModel>(); expectedData.Name = "edited"; await this.categoryService.EditAsync(expectedData.Id, expectedData.Name); AdminCategoryListingServiceModel actualData = context.Categories.First().To <AdminCategoryListingServiceModel>(); Assert.True(actualData.Name == expectedData.Name, "Name not edited properly."); }