public async Task BloodSugarLogService_Create_Fail_Path() { var options = FakeDataDBContext(); using (var context = new BloodSugarDbContext(options)) { var service = new BloodSugarLogService(_userManagerMock.Object, _signInManagerMock.Object, context); // No user in the database var result = await service.Create(new CreateCommandModel { BloodValue = 123 }); Assert.False(result); } }
public async Task BloodSugarLogService_Create_Happ_Path() { var options = FakeDataDBContext(); using (var context = new BloodSugarDbContext(options)) { var service = new BloodSugarLogService(_userManagerMock.Object, _signInManagerMock.Object, context); _userManagerMock.Setup(x => x.FindByEmailAsync("*****@*****.**")) .ReturnsAsync(new ApplicationUser() { UserName = "******", Id = "1234yy" }); var result = await service.Create(new CreateCommandModel { FoodName = "Pilau", BloodValue = 123, Name = "*****@*****.**" }); Assert.True(result); } }
public async Task BloodSugarLogService_Return_PassUserWithNoResultReturnZero() { var options = FakeDataDBContext(); using (var context = new BloodSugarDbContext(options)) { var service = new BloodSugarLogService(_userManagerMock.Object, _signInManagerMock.Object, context); _userManagerMock.Setup(x => x.FindByEmailAsync("*****@*****.**")) .ReturnsAsync(new ApplicationUser() { UserName = "******", Id = "1234" }); var results = await service.GetBloodLogs("*****@*****.**"); var count = results.Count; Assert.Equal(0, count); } }