public void HaveOfficesNoApointmentNeedWithOutAlerts_ShouldBePresentInFinalEmail()
        {
            // Arrange
            var sessionData = new Model.SessionData()
            {
                Cookie = Guid.NewGuid().ToString()
            };
            var cities = new List <Model.DPFCity>()
            {
                new Model.DPFCity()
                {
                    Id = "1", Name = "SÃO PAULO"
                }
            };
            var input = new string[1] {
                "*****@*****.**"
            };
            var offices = new List <Model.DPFOffice>()
            {
                new Model.DPFOffice()
                {
                    Id = "2025", Name = "SÃO PAULO OFFICE A", IsAppointmentMandatory = true
                },
                new Model.DPFOffice()
                {
                    Id = "2026", Name = "SÃO PAULO OFFICE B", IsAppointmentMandatory = false
                },
                new Model.DPFOffice()
                {
                    Id = "2027", Name = "SÃO PAULO OFFICE C", IsAppointmentMandatory = true
                }
            };
            List <Tuple <Model.DPFOffice, IReadOnlyCollection <string> > > officesTuple = new List <Tuple <DPFOffice, IReadOnlyCollection <string> > >();
            string result = null;

            this.emailNotifierMock
            .Setup(a => a.Send(It.IsAny <string[]>(), It.IsAny <string>(), It.IsAny <string>()))
            .Callback <string[], string, string>((to, subject, message) => result = message)
            .Returns(true);
            offices.ForEach(a => officesTuple.Add(new Tuple <DPFOffice, IReadOnlyCollection <string> >(a, a.IsAppointmentMandatory ? new List <string>() : null)));
            Dictionary <DPFCity, List <Tuple <DPFOffice, IReadOnlyCollection <string> > > > dictionaryResult = generateExpectedDictionary(cities, officesTuple);

            var expectedPhrases = new List <string>()
            {
                "SÃO PAULO-SÃO PAULO OFFICE A <font color='blue'>necessita de agendamento e está sem alertas</font>",
                "SÃO PAULO-SÃO PAULO OFFICE B <font color='blue'>não necessita de agendamento e está sem alertas</font>",
                "SÃO PAULO-SÃO PAULO OFFICE C <font color='blue'>necessita de agendamento e está sem alertas</font>",
            };
            var nonExpectedPhrases = new List <string>()
            {
                "Não há destaques no relatório de hoje"
            };

            // Act
            this.appointmentsAvailbilityReportSender.Send(input, dictionaryResult);

            // Assert
            expectedPhrases.ForEach(m => Assert.Contains(m, result));
            nonExpectedPhrases.ForEach(m => Assert.DoesNotContain(m, result));
        }
Ejemplo n.º 2
0
        public async Task HaveOfficesWithOutAlerts_ShouldBePresentInFinalDictionary()
        {
            // Arrange
            var sessionData = new Model.SessionData()
            {
                Cookie = Guid.NewGuid().ToString()
            };
            var cities = new List <Model.DPFCity>()
            {
                new Model.DPFCity()
                {
                    Id = "1", Name = "SÃO PAULO"
                }
            };
            var input   = new ReportInput();
            var offices = new List <Model.DPFOffice>()
            {
                new Model.DPFOffice()
                {
                    Id = "2025", Name = "SÃO PAULO OFFICE A", IsAppointmentMandatory = true
                },
                new Model.DPFOffice()
                {
                    Id = "2026", Name = "SÃO PAULO OFFICE B", IsAppointmentMandatory = false, Alerts = "Closed"
                },
                new Model.DPFOffice()
                {
                    Id = "2027", Name = "SÃO PAULO OFFICE C", IsAppointmentMandatory = true
                }
            };
            List <Tuple <Model.DPFOffice, IReadOnlyCollection <string> > > officesTuple = new List <Tuple <DPFOffice, IReadOnlyCollection <string> > >();
            var alerts = new List <string>()
            {
                "No dates availble"
            };

            this.dpfGatewayMock
            .Setup(a => a.GetAvailbleCities(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>()))
            .Returns(Task.FromResult(
                         new Model.DPFResponse <IReadOnlyCollection <Model.DPFCity> >(cities, sessionData)
                         ));
            this.dpfGatewayMock
            .Setup(a => a.GetAvailbleOffices(It.IsAny <Model.SessionData>(), It.IsAny <string>()))
            .Returns(Task.FromResult(
                         new Model.DPFResponse <IReadOnlyCollection <Model.DPFOffice> >(offices, sessionData)
                         ));
            this.dpfGatewayMock
            .Setup(a => a.GetAppointmentAlertsFromOffice(It.IsAny <Model.SessionData>(), It.IsAny <string>(), It.IsAny <string>(), offices.FirstOrDefault().Id))
            .Returns(Task.FromResult(
                         new Model.DPFResponse <IReadOnlyCollection <string> >(new List <string>(), sessionData)
                         ));
            this.dpfGatewayMock
            .Setup(a => a.GetAppointmentAlertsFromOffice(It.IsAny <Model.SessionData>(), It.IsAny <string>(), It.IsAny <string>(), offices.LastOrDefault().Id))
            .Returns(Task.FromResult(
                         new Model.DPFResponse <IReadOnlyCollection <string> >(alerts, sessionData)
                         ));
            Dictionary <Model.DPFCity, List <Tuple <Model.DPFOffice, IReadOnlyCollection <string> > > > result = null;

            this.appointmentsAvailbilityReportSenderMock
            .Setup(a => a.Send(It.IsAny <string[]>(), It.IsAny <Dictionary <Model.DPFCity, List <Tuple <Model.DPFOffice, IReadOnlyCollection <string> > > > >()))
            .Callback <string[], Dictionary <Model.DPFCity, List <Tuple <Model.DPFOffice, IReadOnlyCollection <string> > > > >((emails, obj) => result = obj)
            .Returns(true);
            offices.ForEach(a => officesTuple.Add(new Tuple <DPFOffice, IReadOnlyCollection <string> >(a,
                                                                                                       a.Id == offices.LastOrDefault().Id ?
                                                                                                       alerts :
                                                                                                       a.IsAppointmentMandatory ? new List <string>() : null)));
            Dictionary <DPFCity, List <Tuple <DPFOffice, IReadOnlyCollection <string> > > > expected = generateExpectedDictionary(cities, officesTuple);

            // Act
            await this.appointmentsAvailbilityReportGenerator.Generate(input, null, null, true);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }