public void TestCanHandleFalse() { var handler = new TransferCommandHandler(); var command = Mock.Of <ICommand>(); var canHandle = handler.CanHandle(command); Assert.False(canHandle); }
public void TestHandleTransferFromDepositToDeposit() { var publisher = new Mock <IEventPublisher>(); var handler = new TransferCommandHandler(); var command = new TransferCommand { Currency = Currencies.Dollars.Of(10), SourceDepositId = Guid.NewGuid(), DestinationDepositId = Guid.NewGuid() }; handler.Handle(command); Assert.False(true); }
public void TestCanHandle() { var handler = new TransferCommandHandler(); var command = new TransferCommand { Currency = Currencies.Dollars.Of(10), SourceDepositId = Guid.NewGuid(), DestinationDepositId = Guid.NewGuid() }; var canHandle = handler.CanHandle(command); Assert.True(canHandle); }
public TransferCommandHandlerTest() { var config = new MapperConfiguration(opts => { opts.AddProfile <BankMappingProfile>(); }); _mapper = config.CreateMapper(); _mediator = Substitute.For <IMediator>(); _unitOfWork = Substitute.For <IUnitOfWork>(); _sut = new TransferCommandHandler(_mapper, _mediator, _unitOfWork); }
public void Setup() { var step1OnJourney1Mock = new Mock <Step>(); step1OnJourney1Mock.SetupGet(x => x.Id).Returns(Step1OnJourney1Id); step1OnJourney1Mock.SetupGet(x => x.Plant).Returns(TestPlant); var step2OnJourney1Mock = new Mock <Step>(); step2OnJourney1Mock.SetupGet(x => x.Id).Returns(Step2OnJourney1Id); step2OnJourney1Mock.SetupGet(x => x.Plant).Returns(TestPlant); var journey1 = new Journey(TestPlant, "J1"); journey1.AddStep(step1OnJourney1Mock.Object); journey1.AddStep(step2OnJourney1Mock.Object); var step1OnJourney2Mock = new Mock <Step>(); step1OnJourney2Mock.SetupGet(x => x.Id).Returns(Step1OnJourney2Id); step1OnJourney2Mock.SetupGet(x => x.Plant).Returns(TestPlant); var step2OnJourney2Mock = new Mock <Step>(); step2OnJourney2Mock.SetupGet(x => x.Id).Returns(Step2OnJourney2Id); step2OnJourney2Mock.SetupGet(x => x.Plant).Returns(TestPlant); var journey2 = new Journey(TestPlant, "J2"); journey2.AddStep(step1OnJourney2Mock.Object); journey2.AddStep(step2OnJourney2Mock.Object); var journeyRepoMock = new Mock <IJourneyRepository>(); journeyRepoMock .Setup(r => r.GetJourneysByStepIdsAsync(new List <int> { Step1OnJourney1Id, Step1OnJourney2Id })) .Returns(Task.FromResult(new List <Journey> { journey1, journey2 })); var reqMock1 = new Mock <TagRequirement>(); reqMock1.SetupGet(r => r.Plant).Returns(TestPlant); var tagId1 = 7; var tagId2 = 8; _tag1 = new Tag(TestPlant, TagType.Standard, "", "", step1OnJourney1Mock.Object, new List <TagRequirement> { reqMock1.Object }); _tag1.SetProtectedIdForTesting(tagId1); var reqMock2 = new Mock <TagRequirement>(); reqMock2.SetupGet(r => r.Plant).Returns(TestPlant); _tag2 = new Tag(TestPlant, TagType.Standard, "", "", step1OnJourney2Mock.Object, new List <TagRequirement> { reqMock2.Object }); _tag2.SetProtectedIdForTesting(tagId2); _tag1.StartPreservation(); _tag2.StartPreservation(); var projectRepoMock = new Mock <IProjectRepository>(); var tagIds = new List <int> { tagId1, tagId2 }; var tagIdsWithRowVersion = new List <IdAndRowVersion> { new IdAndRowVersion(tagId1, _rowVersion1), new IdAndRowVersion(tagId2, _rowVersion2) }; projectRepoMock .Setup(r => r.GetTagsByTagIdsAsync(tagIds)) .Returns(Task.FromResult(new List <Tag> { _tag1, _tag2 })); _command = new TransferCommand(tagIdsWithRowVersion); _dut = new TransferCommandHandler(projectRepoMock.Object, journeyRepoMock.Object, UnitOfWorkMock.Object); }