Esempio n. 1
0
        public async Task GetByIdAsync_WithNonExistentId_ShouldReturnNull()
        {
            var context = BookStoreDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.categoryService = new CategoryService(context);

            CategoryListingServiceModel actualData = await this.categoryService.GetByIdAsync(-1);

            Assert.True(actualData == null);
        }
Esempio n. 2
0
        public async Task GetByIdAsync_WithExistentId_ShouldReturnCorrectResult()
        {
            var context = BookStoreDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.categoryService = new CategoryService(context);

            CategoryListingServiceModel expectedData = context.Categories.First().To <CategoryListingServiceModel>();
            CategoryListingServiceModel 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.");
        }