public void FactorValueMustCallTheSuppliedService()
        {
            //Arrange
            var mockService = new Mock<IFactorsService> {CallBase = true};
            var sut = new CalculationDataContext(new DataContext(), mockService.Object);
            var effectiveDate = DateTime.Now;
            var factorId = Guid.NewGuid();

            //Act
            sut.FactorValue(effectiveDate, factorId);

            //Assert
            mockService.Verify(service => service.FactorValuesById(
                It.Is<Guid>(g => g == factorId)), Times.Once);
        }
        public void ReturnFalseIfThereAreNoCostCodes()
        {
            //Arrange
            var mockService = new Mock<IFactorsService> {CallBase = true};
            var mockContext = new Mock<DataContext> {CallBase = true};
            var mockCostCentres = new FakeDbSet<CostCentre>(new[]
                {
                    new CostCentre {CostCode = "123"},
                    new CostCentre {CostCode = "1234"}
                });

            mockContext
                .SetupGet(context => context.CostCentres)
                .Returns(mockCostCentres);

            var sut = new CalculationDataContext(mockContext.Object, mockService.Object);

            //Act
            var actual = sut.CostCodeValid("1235");

            //Assert
            Assert.IsFalse(actual);
        }
        public void EntryIsDuplicateIsFalseForNonMatchingHash()
        {
            //Arrange
            var mockService = new Mock<IFactorsService> { CallBase = true };
            var mockContext = new Mock<DataContext> { CallBase = true };
            var entryId = Guid.NewGuid();
            var testEntry = new TestEntry { TestValue = "test3",Id = entryId};
            var mockDataEntry = new FakeDbSet<DataEntry>(new[]
                {
                    new TestEntry {TestValue = "test"},
                    new TestEntry {TestValue = "test"},
                    testEntry
                });

            mockContext
                .SetupGet(context => context.DataEntries)
                .Returns(mockDataEntry);

            var sut = new CalculationDataContext(mockContext.Object, mockService.Object);

            //Act
            var actual = sut.EntryIsDuplicate(entryId, testEntry.Hash);

            //Assert
            Assert.IsFalse(actual);
        }