public void WhenCreate_ThenReturnsClinic()
        {
            var person = new Person
            {
                Id = "apersonid"
            };

            this.personService.Setup(ps => ps.Get(It.IsAny <string>()))
            .Returns(person);
            var city   = Location.Cities[0];
            var street = Location.Streets[0];
            var entity = new ClinicEntity(this.logger.Object, this.idFactory.Object);

            this.storage.Setup(s =>
                               s.Save(It.IsAny <ClinicEntity>()))
            .Returns(entity);

            var result = this.clinicsApplication.Create(this.caller.Object, 2010, city, street);

            result.Id.Should().Be("anid");
            this.storage.Verify(s =>
                                s.Save(It.Is <ClinicEntity>(e =>
                                                            e.Owner == "apersonid" &&
                                                            e.Location.Country == 2010 &&
                                                            e.Location.City == city &&
                                                            e.Location.Street == street &&
                                                            e.Managers.Managers.Single() == "apersonid")));
        }
        public void WhenAddDoctor_ThenAddsDoctorToClinic()
        {
            var doctor = new ClinicDoctor("adoctorid", "afirstname", "alastname");
            var entity = new ClinicEntity(this.logger.Object, this.idFactory.Object);

            entity.RegisterDoctor(doctor);

            this.personService.Setup(ps => ps.Create(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new Person
            {
                Id = "apersonid", Name = new PersonName {
                    FirstName = "afirstname", LastName = "alastname"
                }
            });
            this.storage.Setup(s => s.Load(It.Is <Identifier>(i => i == "aclinicid")))
            .Returns(entity);
            this.storage.Setup(s => s.Save(It.Is <ClinicEntity>(e => e.Unavailabilities.Count == 1)))
            .Returns(entity);

            var result =
                this.clinicsApplication.RegisterDoctor(this.caller.Object, "aclinicid", "afirstname", "alastname");

            result.Should().NotBeNull();
            this.personService.Verify(ps => ps.Create("afirstname", "alastname"));
        }
        public static Clinic ToClinic(this ClinicEntity entity)
        {
            var dto = entity.ConvertTo <Clinic>();

            dto.Id               = entity.Id;
            dto.Address          = entity.Location.ConvertTo <ClinicAddress>();
            dto.Owner            = entity.Owner.ToClinicOwner();
            dto.PracticeManagers = entity.Managers.ToPracticeManagers();

            return(dto);
        }
Exemple #4
0
        public void Initialize()
        {
            this.logger            = new Mock <ILogger>();
            this.identifierFactory = new Mock <IIdentifierFactory>();
            var entityCount = 0;

            this.identifierFactory.Setup(f => f.Create(It.IsAny <IIdentifiableEntity>()))
            .Returns((IIdentifiableEntity e) =>
            {
                if (e is UnavailabilityEntity)
                {
                    return($"anunavailbilityid{++entityCount}".ToIdentifier());
                }
                return("anid".ToIdentifier());
            });
            this.entity = new ClinicEntity(this.logger.Object, this.identifierFactory.Object);
        }
        public Clinic Create(ICurrentCaller caller, int country, string city, string street)
        {
            caller.GuardAgainstNull(nameof(caller));

            var owner = this.personsService.Get(caller.Id)
                        .ToClinicOwner();

            var clinic = new ClinicEntity(this.logger, this.idFactory);

            clinic.SetOwnership(new ClinicsDomain.ClinicOwner(owner.Id));
            clinic.SetLocation(new Location(country, city, street));

            var created = this.storage.Save(clinic);

            this.logger.LogInformation("Clinic {Id} was created by {Caller}", created.Id, caller.Id);

            return(created.ToClinic());
        }
        public void WhenOffline_ThenDoctorOffline()
        {
            var fromUtc = DateTime.UtcNow.AddMinutes(1);
            var toUtc   = fromUtc.AddMinutes(1);
            var entity  = new ClinicEntity(this.logger.Object, this.idFactory.Object);

            entity.SetLocation(new Location(2010, Location.Cities[0], Location.Streets[0]));
            entity.SetOwnership(new ClinicOwner("anownerid"));
            entity.Register(new ClinicLicense(ClinicLicense.Jurisdictions[0], "anumber"));
            this.storage.Setup(s => s.Load(It.Is <Identifier>(i => i == "aclinicid")))
            .Returns(entity);
            this.storage.Setup(s => s.Save(It.Is <ClinicEntity>(e => e.Unavailabilities.Count == 1)))
            .Returns(entity);

            var result = this.clinicsApplication.OfflineDoctor(this.caller.Object, "aclinicid", fromUtc, toUtc);

            result.Should().NotBeNull();
        }
        public void WhenRegister_ThenRegistersClinic()
        {
            var entity = new ClinicEntity(this.logger.Object, this.idFactory.Object);

            this.storage.Setup(s => s.Load(It.Is <Identifier>(i => i == "aclinicid")))
            .Returns(entity);
            this.storage.Setup(s =>
                               s.Save(It.Is <ClinicEntity>(
                                          e => e.License == new ClinicLicense(ClinicLicense.Jurisdictions[0], "anumber"))))
            .Returns(entity);

            var result =
                this.clinicsApplication.Register(this.caller.Object, "aclinicid", ClinicLicense.Jurisdictions[0],
                                                 "anumber");

            result.License.Should().BeEquivalentTo(new Application.Resources.ClinicLicense
            {
                Jurisdiction = ClinicLicense.Jurisdictions[0], CertificateNumber = "anumber"
            });
            result.Should().NotBeNull();
        }
Exemple #8
0
 public async Task UpdateAsync(ClinicEntity clinic)
 {
     _dbContext.Update(clinic);
     await _dbContext.SaveChangesAsync();
 }
 public ClinicEntity Save(ClinicEntity clinic)
 {
     this.clinicEventStreamStorage.Save(clinic);
     return(clinic);
 }