Example #1
0
        public async Task GetAllContacts_Should_not_return_soft_deleted_contacts()
        {
            // Arrange
            await ContactHelpers.SeedContacts(dbAccess, mapper);

            var deleteClient = new DeleteContactCommand()
            {
                ContactId = 2
            };
            var deleteHandler = new DeleteContactHandler(dbAccess, mapper);
            await deleteHandler.Handle(deleteClient, CancellationToken.None);

            var query   = new GetAllContactsQuery();
            var handler = new GetAllContactsHandler(dbAccess, mapper);

            // Act
            var result = await handler.Handle(query, CancellationToken.None);

            // Assert
            Assert.Single(result);
            Assert.Collection(result,
                              a =>
            {
                Assert.Equal(1, a.ContactId);
                Assert.Equal("Joe Bloggs", a.FullName);
            }
                              );
        }
Example #2
0
        public async Task GetAllContacts_Should_return_all_contacts()
        {
            // Arrange
            await ContactHelpers.SeedContacts(dbAccess, mapper);

            var query   = new GetAllContactsQuery();
            var handler = new GetAllContactsHandler(dbAccess, mapper);

            // Act
            var result = await handler.Handle(query, CancellationToken.None);

            // Assert
            Assert.Equal(2, result.Count);
            Assert.Collection(result,
                              a =>
            {
                Assert.Equal(1, a.ContactId);
                Assert.Equal("Joe Bloggs", a.FullName);
            },
                              b =>
            {
                Assert.Equal(2, b.ContactId);
                Assert.Equal("Sally Bloggs", b.FullName);
            }
                              );
        }