Exemple #1
0
        public async Task ReturnTheCorrectContactInformationViewModel()
        {
            var sut = new OrganizationContactQueryHandler(Context);

            var message = new OrganizationContactQuery {
                OrganizationId = 1
            };

            var result = await sut.Handle(message);

            var organization = await Context.Organizations
                               .AsNoTracking()
                               .Include(l => l.Location)
                               .Include(oc => oc.OrganizationContacts).ThenInclude(c => c.Contact)
                               .SingleOrDefaultAsync(o => o.Id == message.OrganizationId);

            var contact = organization.OrganizationContacts?.SingleOrDefault(tc => tc.ContactType == (int)ContactTypes.Primary)?.Contact;

            result.ShouldNotBeNull();
            result.ShouldBeOfType <ContactInformationViewModel>();
            result.Location.Id.ShouldBe(organization.Location.ToModel().Id);

            Assert.True(result.Email == contact.Email &&
                        result.FirstName == contact.FirstName &&
                        result.LastName == contact.LastName &&
                        result.PhoneNumber == contact.PhoneNumber);
        }
        public async Task ReturnTheCorrectContactInformationViewModel()
        {
            var sut = new OrganizationContactQueryHandler(Context);

            var message = new OrganizationContactQuery { OrganizationId = 1 };

            var result = await sut.Handle(message);

            var organization = await Context.Organizations
                .AsNoTracking()
                .Include(l => l.Location)
                .Include(oc => oc.OrganizationContacts).ThenInclude(c => c.Contact)
                .SingleOrDefaultAsync(o => o.Id == message.OrganizationId);

            var contact = organization.OrganizationContacts?.SingleOrDefault(tc => tc.ContactType == (int)ContactTypes.Primary)?.Contact;

            result.ShouldNotBeNull();
            result.ShouldBeOfType<ContactInformationViewModel>();
            result.Location.Id.ShouldBe(organization.Location.ToModel().Id);

            Assert.True(result.Email == contact.Email &&
                        result.FirstName == contact.FirstName &&
                        result.LastName == contact.LastName &&
                        result.PhoneNumber == contact.PhoneNumber);
        }
        public async Task ReturnUnpopulatedContactInformationViewModelIfOrganizationIsNull()
        {
            var sut = new OrganizationContactQueryHandler(Context);

            var message = new OrganizationContactQuery {OrganizationId = 2};

            var result = await sut.Handle(message);

            result.ShouldNotBeNull();
            result.ShouldBeOfType<ContactInformationViewModel>();

            var contactInfo = new ContactInformationViewModel();
            Assert.True(result.FirstName == contactInfo.FirstName &&
                        result.LastName == contactInfo.LastName &&
                        result.Email == contactInfo.Email &&
                        result.Location == contactInfo.Location &&
                        result.PhoneNumber == contactInfo.PhoneNumber);
        }
Exemple #4
0
        public async Task ReturnUnpopulatedContactInformationViewModelIfOrganizationIsNull()
        {
            var sut = new OrganizationContactQueryHandler(Context);

            var message = new OrganizationContactQuery {
                OrganizationId = 2
            };

            var result = await sut.Handle(message);

            result.ShouldNotBeNull();
            result.ShouldBeOfType <ContactInformationViewModel>();

            var contactInfo = new ContactInformationViewModel();

            Assert.True(result.FirstName == contactInfo.FirstName &&
                        result.LastName == contactInfo.LastName &&
                        result.Email == contactInfo.Email &&
                        result.Location == contactInfo.Location &&
                        result.PhoneNumber == contactInfo.PhoneNumber);
        }