예제 #1
0
        public void ShouldDeleteLeads()
        {
            var service       = new LeadsService();
            var leads         = service.GetLeads().ToList();
            var leadToDelete  = leads.OrderBy(x => Guid.NewGuid()).First();
            var originalCount = leads.Count();

            service.Delete(leadToDelete.Id.Value);
            var updatedLeads = service.GetLeads().ToList();

            Assert.DoesNotContain(leadToDelete, updatedLeads);
            Assert.All(updatedLeads, l => Assert.NotEqual(leadToDelete.Id, l.Id));
            Assert.Equal(originalCount - 1, updatedLeads.Count());
        }
예제 #2
0
        public void ShouldAddLeads()
        {
            var service       = new LeadsService();
            var leads         = service.GetLeads().ToList();
            var originalCount = leads.Count();
            var expectedId    = leads.Max(l => l.Id) + 1;
            var newLead       = CreateLead();
            var result        = service.Add(newLead);
            var updatedLeads  = service.GetLeads().ToList();

            Assert.Contains(newLead, updatedLeads);
            Assert.Equal(newLead, result);
            Assert.Equal(newLead.Id, expectedId);
            Assert.Equal(originalCount + 1, updatedLeads.Count());
        }
예제 #3
0
        public void ShouldUpdateLeads()
        {
            var service         = new LeadsService();
            var leads           = service.GetLeads().ToList();
            var leadToUpdate    = leads.OrderBy(x => Guid.NewGuid()).First().Clone();
            var originalCount   = leads.Count();
            var originalAddress = leadToUpdate.Address;

            leadToUpdate.Address = Faker.Address.StreetAddress();
            service.Update(leadToUpdate);
            var updatedLeads = service.GetLeads().ToList();

            Assert.Contains(leadToUpdate, updatedLeads);
            Assert.All(updatedLeads, l => Assert.NotEqual(originalAddress, l.Address));
            Assert.Equal(originalCount, updatedLeads.Count());
        }
예제 #4
0
        public void ShouldGetLeads()
        {
            var service = new LeadsService();
            var leads   = service.GetLeads();

            Assert.Equal(5, leads.Count());
        }