Ejemplo n.º 1
0
        public void Duplicate_company_number_check_throws_exception()
        {
            _repository.Setup(x => x.DuplicateCompanyNumberExists(It.IsAny <Guid>(), It.IsAny <string>()))
            .Throws(new Exception("Unit test exception"));

            var logger  = new Mock <ILogger <DuplicateCompanyNumberCheckHandler> >();
            var handler = new DuplicateCompanyNumberCheckHandler(logger.Object, _repository.Object);

            var request = new DuplicateCompanyNumberCheckRequest
            {
                CompanyNumber  = "10001000",
                OrganisationId = Guid.NewGuid()
            };

            Func <Task> result = async() => await
                                 handler.Handle(request, new CancellationToken());

            result.Should().Throw <ApplicationException>();
        }
Ejemplo n.º 2
0
        public void Duplicate_company_number_check_returns_match()
        {
            var response = new DuplicateCheckResponse
            {
                DuplicateFound            = true,
                DuplicateOrganisationName = "Legal Name"
            };

            _repository.Setup(x => x.DuplicateCompanyNumberExists(It.IsAny <Guid>(), It.IsAny <string>())).ReturnsAsync(response);

            var logger  = new Mock <ILogger <DuplicateCompanyNumberCheckHandler> >();
            var handler = new DuplicateCompanyNumberCheckHandler(logger.Object, _repository.Object);

            var request = new DuplicateCompanyNumberCheckRequest
            {
                CompanyNumber  = "10001000",
                OrganisationId = Guid.NewGuid()
            };
            var result = handler.Handle(request, new CancellationToken()).GetAwaiter().GetResult();

            result.DuplicateFound.Should().BeTrue();
        }