Пример #1
0
        public void Add_WhenFixturePositionIsNotAvailable_ShouldThrowLogicException()
        {
            // Arrange
            DebitForAddDto        debitForAddDto    = new DebitForAddDto();
            IDataResult <Fixture> fixtureDataResult = new SuccessDataResult <Fixture>(new Fixture()
            {
                FixturePositionId = 2
            });
            var mockDebitDal       = new MockDebitDal().MockAdd(new Debit());
            var mockFixtureService = new MockFixtureService().MockGetById(fixtureDataResult).MockUpdatePostiton(new SuccessResult());
            var sut = new DebitManager(mockDebitDal.Object, mockFixtureService.Object);

            // Act & Assert
            Assert.Throws <LogicException>(() => sut.Add(debitForAddDto));
        }
Пример #2
0
        public void Delete_WhenFixturePositionIsNotDebit_ShouldThrowLogicException()
        {
            // Arrange
            Guid debitId = Guid.NewGuid();
            IDataResult <Fixture> fixtureDataResult = new SuccessDataResult <Fixture>(new Fixture()
            {
                FixturePositionId = 0
            });
            var mockDebitDal       = new MockDebitDal().MockUpdate().MockGet(new Debit());
            var mockFixtureService = new MockFixtureService().MockGetById(fixtureDataResult).MockUpdatePostiton(new SuccessResult());
            var sut = new DebitManager(mockDebitDal.Object, mockFixtureService.Object);

            // Act & Assert
            Assert.Throws <LogicException>(() => sut.Delete(debitId));
        }
Пример #3
0
        public void Delete_WhenDeletedDebit_ShouldUpdateReturnStatus()
        {
            // Arrange
            Guid debitId = Guid.NewGuid();
            IDataResult <Fixture> fixtureDataResult = new SuccessDataResult <Fixture>(new Fixture()
            {
                FixturePositionId = 2
            });
            var mockDebitDal       = new MockDebitDal().MockUpdate().MockGet(new Debit());
            var mockFixtureService = new MockFixtureService().MockGetById(fixtureDataResult).MockUpdatePostiton(new SuccessResult());
            var sut = new DebitManager(mockDebitDal.Object, mockFixtureService.Object);

            // Act
            sut.Delete(debitId);

            // Assert
            mockDebitDal.VerifyUpdate(Times.Once());
        }
Пример #4
0
        public void Add_WhenAddedNewDebit_ShouldAddAndReturnId()
        {
            // Arrange
            DebitForAddDto        debitForAddDto    = new DebitForAddDto();
            IDataResult <Fixture> fixtureDataResult = new SuccessDataResult <Fixture>(new Fixture()
            {
                FixturePositionId = 1
            });
            var mockDebitDal       = new MockDebitDal().MockAdd(new Debit());
            var mockFixtureService = new MockFixtureService().MockGetById(fixtureDataResult).MockUpdatePostiton(new SuccessResult());
            var sut = new DebitManager(mockDebitDal.Object, mockFixtureService.Object);

            // Act
            var result = sut.Add(debitForAddDto);

            // Assert
            Assert.Equal(new Guid(), result.Data);
        }