public void TestFindOne() { string displayName = "Some display name"; User user = new User() { DisplayName = displayName }; using (ApiContext context = new ApiContext(dbOptions)) { context.Users.Add(user); context.Users.Add(new User() { DisplayName = "Another random user" }); context.SaveChanges(); } using (ApiContext context = new ApiContext(dbOptions)) { UserService service = new UserService(context); Assert.AreNotEqual(null, service.FindOne(user.Id)); Assert.AreEqual(displayName, service.FindOne(user.Id).DisplayName); } }
public void TestFindOneInvalid() { User user = new User() { DisplayName = "Some display name" }; using (ApiContext context = new ApiContext(dbOptions)) { context.Users.Add(user); context.Users.Add(new User() { DisplayName = "Another random user" }); context.SaveChanges(); } using (ApiContext context = new ApiContext(dbOptions)) { UserService service = new UserService(context); Assert.IsNull(service.FindOne(user.Id + 2)); } }