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

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

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

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

            //Assert
            Assert.IsTrue(actual);
        }
        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 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);
        }