Пример #1
0
        public async Task Handle_Calls_GetAcceptedLeadsAsync()
        {
            //Arrange
            _leadManagementRepository
            .Setup(_ => _.GetAcceptedLeadsAsync(CancellationToken.None))
            .ReturnsAsync(new List <AcceptedLead>());

            //Act
            var query = new GetAcceptedLead.Query();
            await _target.Handle(query, CancellationToken.None);

            //Assert
            _leadManagementRepository.Verify(_ => _.GetAcceptedLeadsAsync(CancellationToken.None), Times.Once);
        }
Пример #2
0
        public async Task Handle_Maps_Data()
        {
            //Arrange
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            var lead = new AcceptedLead
            {
                Id           = 1,
                Area         = "Sydney",
                Category     = "Painter",
                ContactEmail = "*****@*****.**",
                ContactName  = "Alex Nouri",
                ContactPhone = "893398498",
                CreatedAt    = new System.DateTime(2020, 03, 20, 18, 20, 22).ToUniversalTime(),
                Description  = "descp",
                Postcode     = "1234",
                Price        = 1290
            };

            _leadManagementRepository
            .Setup(_ => _.GetAcceptedLeadsAsync(CancellationToken.None))
            .ReturnsAsync(new List <AcceptedLead> {
                lead
            });

            //Act
            var query  = new GetAcceptedLead.Query();
            var result = await _target.Handle(query, CancellationToken.None);

            //Assert
            Assert.Single(result);
            var mappedLead = result.First();

            Assert.Equal(lead.Id, mappedLead.Id);
            Assert.Equal(lead.Category, mappedLead.Category);
            Assert.Equal(lead.ContactEmail, mappedLead.ContactEmail);
            Assert.Equal(lead.ContactPhone, mappedLead.ContactPhone);
            Assert.Equal("Alex", mappedLead.ContactFirstName);
            Assert.Equal("Nouri", mappedLead.ContactLastName);
            Assert.Equal("05:20 PM", mappedLead.CreatedAtTime);
            Assert.Equal("March 20", mappedLead.CreatedAtDate);
            Assert.Equal(lead.Description, mappedLead.Description);
        }