public void GetAuthorByNameTest_AuthorFirstInQuery() { var data = GetFakeAuthor(50); var expected = data .Where(a => a.Name.Contains("a")) .ToList(); var context = CreateDbContext(data); var service = new BookStoreService(context.Object); // act var actual = service.GetAuthorService("a"); // assert Assert.Equal(expected.First(), actual.First()); }
public void PostAuthorTest_InsertNewAuthor() { var data = GetFakeAuthor(10); var expected = "New Actor"; dynamic jsonObject = new JObject(); jsonObject.name = expected; var context = CreateDbContext(data); var service = new BookStoreService(context.Object); // act service.PostAuthorService(jsonObject); var actual = service.GetAuthorService(expected).Count(); // assert Assert.Equal(1, actual); }