Inheritance: IUserWeightBusinessLogic
        public void shouldGetWeight()
        {
            userWeightRepositoryMock.Setup(x => x.FindByDate(expectedUserWeight.User, expectedUserWeight.Date)).Returns(expectedUserWeight);

            var fetchedUserWeight = new UserWeightBusinessLogic(userWeightRepositoryMock.Object).GetUserWeight(expectedUserWeight.User, expectedUserWeight.Date);

            Assert.That(ReferenceEquals(fetchedUserWeight, expectedUserWeight));
            userWeightRepositoryMock.VerifyAll();
        }
        public void shouldGetUserWeightHistoryForUser()
        {
            var originalUserWeightHistory = new List<UserWeight> {new UserWeight(), new UserWeight()};
            userWeightRepositoryMock.Setup(x => x.GetHistoryList(It.Is<User>(y => y.Username == expectedUserWeightMock.Object.User.Username))).Returns(originalUserWeightHistory);

            var returnedUserWeightHistory = new UserWeightBusinessLogic(userWeightRepositoryMock.Object).GetHistoryList(expectedUserWeightMock.Object.User);

            Assert.That(ReferenceEquals(returnedUserWeightHistory, originalUserWeightHistory));
            userWeightRepositoryMock.VerifyAll();
        }
 public void shouldGetWeightHístoryLineForGraph()
 {
     var firstdate = DateTime.Now.AddDays(-5).Date;
     var lastdate = DateTime.Now.Date;
     var expected = 22;
     var originalUserWeightHistory = new List<UserWeight> {new UserWeight{Date = firstdate, Weight = expected}, new UserWeight{Date = lastdate, Weight = 34}};
     userWeightRepositoryMock.Setup(x => x.GetHistoryList(It.Is<User>(y => y.Username == expectedUserWeightMock.Object.User.Username))).Returns(originalUserWeightHistory);
     ILine line = new UserWeightBusinessLogic(userWeightRepositoryMock.Object).GetHistoryLine(expectedUserWeightMock.Object.User);
     Assert.That(line.GetFirstDate(), Is.EqualTo(firstdate));
     Assert.That(line.GetLastDate(), Is.EqualTo(lastdate));
     Assert.That(line.GetValue(firstdate).Value, Is.EqualTo(expected));
 }
        public void shouldSaveUserWeight()
        {
            userWeightRepositoryMock.Setup(z => z.SaveOrUpdate(It.Is<UserWeight>(x => x.Date == expectedUserWeight.Date && x.User.Username == expectedUserWeight.User.Username && x.Weight == expectedUserWeight.Weight))).Returns(expectedUserWeight);

            var createdUserWeight = new UserWeightBusinessLogic(userWeightRepositoryMock.Object).SaveWeight(expectedUserWeight.User, expectedUserWeight.Weight, expectedUserWeight.Date);

            Assert.That(ReferenceEquals(createdUserWeight, expectedUserWeight));
            userWeightRepositoryMock.VerifyAll();
        }
        public void shouldOverwriteUserWeight()
        {
            var userWeightId = 62;
            expectedUserWeightMock.Setup(x => x.Id).Returns(userWeightId);

            userWeightRepositoryMock.Setup(x => x.FindByDate(expectedUserWeight.User, expectedUserWeight.Date)).Returns(expectedUserWeight);

            var newWeight = 75M;
            userWeightRepositoryMock.Setup(z => z.SaveOrUpdate(It.Is<UserWeight>(x => x.Weight == newWeight && x.Id == userWeightId))).Returns(expectedUserWeight);

            var createdUserWeight = new UserWeightBusinessLogic(userWeightRepositoryMock.Object).SaveWeight(expectedUserWeight.User, newWeight, expectedUserWeight.Date);

            userWeightRepositoryMock.VerifyAll();
            Assert.That(createdUserWeight.Weight, Is.EqualTo( newWeight));
        }