Example #1
0
        public async Task Test_AddLeadsCommand_AddsLeadSuccessfully()
        {
            // Arrange
            await _apiFactory.SeedDatabase(DataSeeds);

            var addLeadCommand = new AddLead {
                Name = "Test Tester", ZipCode = "60640"
            };
            var session = _leadServicebusHostFactory.Services.GetService <IMessageSession>();

            // Act
            var result = await EndpointFixture.ExecuteAndWaitForHandled <AddLead>(
                () => session.SendLocal(addLeadCommand));

            // Assert
            var successMessages = result.SentMessages.OfType <LeadAddedSuccessfully>();

            Assert.IsTrue(successMessages.Count() > 0);
            Assert.IsTrue(successMessages.First().LeadID > 0);

            var lead = await _leadClient.GetLeadAsync(successMessages.First().LeadID);

            Assert.AreEqual(successMessages.First().LeadID, lead.LeadID);
            Assert.AreEqual(addLeadCommand.Name, lead.Name);
            Assert.AreEqual(addLeadCommand.ZipCode, lead.ZipCode);
        }
Example #2
0
        public async Task Test_AddLead()
        {
            // Arrange
            //var apiFactory = new LeadApiFactory();
            await _apiFactory.SeedDatabase(async context =>
            {
                await context.SaveChangesAsync();
            });

            var client = _apiFactory.CreateLeadClient();
            var lead   = new LeadApi.Client.Lead {
                Name = "Phill", ZipCode = "60640"
            };

            // Act
            var result = await client.AddLeadAsync(lead);

            // Assert
            Assert.IsTrue(result.LeadID > 0);
            Assert.AreEqual(result.Name, lead.Name);
            Assert.AreEqual(result.ZipCode, lead.ZipCode);
        }