Esempio n. 1
0
        public async Task CalculateAsync_WhenCalled_AssertCalculateAsyncWasCalledOnEachInfo()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            IEnumerable <Mock <ICreditInfo> > infoMockCollection = new List <Mock <ICreditInfo> >
            {
                _fixture.BuildCreditInfoMock(),
                                              _fixture.BuildCreditInfoMock(),
                                              _fixture.BuildCreditInfoMock(),
                                              _fixture.BuildCreditInfoMock(),
                                              _fixture.BuildCreditInfoMock(),
                                              _fixture.BuildCreditInfoMock(),
                                              _fixture.BuildCreditInfoMock()
            };

            sut.Add(infoMockCollection.Select(infoMock => infoMock.Object).ToArray());

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            await sut.CalculateAsync(statusDate);

            foreach (Mock <ICreditInfo> infoMock in infoMockCollection)
            {
                infoMock.Verify(m => m.CalculateAsync(It.Is <DateTime>(value => value == statusDate.Date)), Times.Once);
            }
        }
Esempio n. 2
0
        public async Task CalculateAsync_WhenCalled_AssertCalculateWasCalledOnSut()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            Sut result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            Assert.That(result.CalculateWasCalled, Is.True);
        }
Esempio n. 3
0
        public async Task CalculateAsync_WhenCalled_ReturnsSameInfoCollectionBase()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            IInfoCollection <ICreditInfo, Sut> result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            Assert.That(result, Is.SameAs(sut));
        }
Esempio n. 4
0
        public async Task CalculateAsync_WhenCalled_AssertCalculateWasCalledWithSameStatusDate()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            Sut      result     = await sut.CalculateAsync(statusDate);

            Assert.That(result.CalculateCalledWithStatusDate, Is.EqualTo(statusDate.Date));
        }
Esempio n. 5
0
        public async Task CalculateAsync_WhenCalled_ReturnsSameInfoCollectionBaseWhereStatusDateEqualDateFromCall()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            IInfoCollection <ICreditInfo, Sut> result = await sut.CalculateAsync(statusDate);

            Assert.That(result.StatusDate, Is.EqualTo(statusDate.Date));
        }
Esempio n. 6
0
        public async Task CalculateAsync_WhenCalled_AssertCalculateWasCalledWithCalculatedInfoCollection()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            IEnumerable <ICreditInfo> calculatedInfoCollection = new List <ICreditInfo>
            {
                _fixture.BuildCreditInfoMock().Object,
                                      _fixture.BuildCreditInfoMock().Object,
                                      _fixture.BuildCreditInfoMock().Object,
                                      _fixture.BuildCreditInfoMock().Object,
                                      _fixture.BuildCreditInfoMock().Object,
                                      _fixture.BuildCreditInfoMock().Object,
                                      _fixture.BuildCreditInfoMock().Object
            };

            sut.Add(calculatedInfoCollection.Select(calculatedInfo => _fixture.BuildCreditInfoMock(calculatedCreditInfo: calculatedInfo).Object).ToArray());

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            Sut      result     = await sut.CalculateAsync(statusDate);

            Assert.That(result.CalculateCalledWithCalculatedInfoCollection.All(calculatedInfo => calculatedInfoCollection.Contains(calculatedInfo)), Is.True);
        }
Esempio n. 7
0
        public async Task CalculateAsync_WhenCalledMultipleTimesWithSameStatusDate_ReturnsSameInfoCollectionBase()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            IInfoCollection <ICreditInfo, Sut> result = await((IInfoCollection <ICreditInfo, Sut>)await((IInfoCollection <ICreditInfo, Sut>) await sut.CalculateAsync(statusDate)).CalculateAsync(statusDate)).CalculateAsync(statusDate);

            Assert.That(result, Is.SameAs(sut));
        }
Esempio n. 8
0
        public async Task CalculateAsync_WhenCalledMultipleTimesWithSameStatusDate_AssertAlreadyCalculatedWasCalledTwiceOnSut()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            Sut      result     = await((IInfoCollection <ICreditInfo, Sut>)await((IInfoCollection <ICreditInfo, Sut>) await sut.CalculateAsync(statusDate)).CalculateAsync(statusDate)).CalculateAsync(statusDate);

            Assert.That(result.AlreadyCalculatedWasCalledTimes, Is.EqualTo(2));
        }