コード例 #1
0
        public async void DeleteAsync_WhenEntityDoesNotExist_ShouldNotDeleteEntity_Test()
        {
            // Arrange
            var sut         = new DoctorRepository(this.GetDatabaseConnection(), this.converter, this.logger.Object);
            var id          = ObjectId.GenerateNewId().ToString();
            var beforeCount = sut.GetAllAsync().Result.Count();

            // Act
            await sut.DeleteAsync(id);

            // Assert
            var afterCount = sut.GetAllAsync().Result.Count();

            Assert.Equal(beforeCount, afterCount);
        }
コード例 #2
0
        public async void UpdateAsync_WhenEntityExists_ShouldUpdateEntity_Test()
        {
            // Arrange
            var sut = new DoctorRepository(this.GetDatabaseConnection(), this.converter, this.logger.Object);
            await sut.InsertAsync(this.testEntity, "TestUser");

            this.testEntity.FirstName = "Valentino";
            this.testEntity.LastName  = "Rossi";

            // Act
            await sut.UpdateAsync(this.testEntity, "TestUserForUpdate");

            // Assert
            var entities      = sut.GetAllAsync().Result.ToList();
            var updatedResult = entities.First(a => a.Id == this.testEntity.Id);

            Assert.Equal("Valentino", updatedResult.FirstName);
            Assert.Equal("Rossi", updatedResult.LastName);

            Assert.NotEqual(DateTime.MinValue, this.testEntity.Created);
            Assert.NotEqual(DateTime.MinValue, this.testEntity.Updated);
            Assert.True(this.testEntity.Updated > this.testEntity.Created);
            Assert.Equal("TestUser", this.testEntity.CreatedBy);
            Assert.Equal("TestUserForUpdate", this.testEntity.UpdatedBy);
        }
コード例 #3
0
        public async void GetAllAsync_ShouldReturnNotNullResult_Test()
        {
            // Arrange
            var sut = new DoctorRepository(this.GetDatabaseConnection(), this.converter, this.logger.Object);

            // Act
            var result = await sut.GetAllAsync();

            // Assert
            var locations = result.ToList();

            Assert.NotNull(locations);
        }
コード例 #4
0
        public async void DeleteAsync_WhenEntityExists_ShouldDeleteEntity_Test()
        {
            // Arrange
            var sut = new DoctorRepository(this.GetDatabaseConnection(), this.converter, this.logger.Object);
            await sut.InsertAsync(this.testEntity, string.Empty);

            // Act
            await sut.DeleteAsync(this.testEntity.Id);

            // Assert
            var entities = sut.GetAllAsync().Result.ToList();

            Assert.DoesNotContain(entities, a => string.Equals(a.Id, this.testEntity.Id));
        }
コード例 #5
0
        public async void UpdateAsync_WhenEntityDoesNotExist_ShouldNotUpdateEntity_Test()
        {
            // Arrange
            var sut = new DoctorRepository(this.GetDatabaseConnection(), this.converter, this.logger.Object);

            // Act
            await sut.UpdateAsync(this.testEntity, "TestUserForUpdate");

            // Assert
            var entities      = sut.GetAllAsync().Result.ToList();
            var updatedResult = entities.FirstOrDefault(a => a.Id == this.testEntity.Id);

            Assert.Null(updatedResult);
        }
コード例 #6
0
        public void Given_DoctorRepository_When_AddAsyncingADoctor_Then_TheDoctorShouldBeProperlySaved()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("Daniel", "Oana", "*****@*****.**", "parola", "0746524459", "bla", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu");

                //Act
                await repository.AddAsync(doctor);

                //Assert
                Assert.AreEqual(repository.GetAllAsync().Result.Count, 1);
            });
        }
コード例 #7
0
        public void Given_DoctorRepository_When_AddAsyncingADoctor_Then_TheDoctorShouldBeProperlySaved()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);

                //Act
                await repository.AddAsync(doctor);

                //Assert
                string[] includes = { };
                Assert.AreEqual(repository.GetAllAsync(includes).Result.Count, 1);
            });
        }