コード例 #1
0
        public async Task CanAddPatient()
        {
            //Arrange
            var createPatientVm = new CreatePatientVm {
                Name = "PatientX",
                Age  = 13
            };
            var dbContext = GetDbContext(nameof(CanAddPatient));
            var sut       = new ClinicService(dbContext);

            //Action
            await sut.AddPatientAsync(createPatientVm);

            //Assert
            var eavEntity = await dbContext.Entities
                            .AsNoTracking()
                            .WithAttributes()
                            .SingleAsync();

            eavEntity.Should().NotBeNull();
            eavEntity.EntityType.Should().Be(EntityType.Patient);

            eavEntity.AttributeValues.Should()
            .NotBeNullOrEmpty()
            .And.HaveCount(2);

            var name = eavEntity.AttributeValues.Single(x => x.AttributeType == AttributeType.PatientName).Value;

            name.Should().Be(createPatientVm.Name);

            var age = eavEntity.AttributeValues.Single(x => x.AttributeType == AttributeType.PatientAge).Value;

            age.Should().Be(createPatientVm.Age.ToString());
        }