public void GetPropertiesSuccess()
        {
            //Arrange
            var propertyRepository = new PropertyRepository(_container);
            var dbContext          = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var properties         = TestDataRepository.GetProperties();

            foreach (var item in properties)
            {
                propertyRepository.CreateProperty(item);
            }

            //Act
            var result     = propertyRepository.GetProperties();
            var resultItem = result.First();

            //Assert
            Assert.NotNull(result);
            Assert.True(result.Count > 0);
            Assert.NotNull(resultItem);
            Assert.NotEqual(resultItem.Id, Guid.Empty);
            Assert.True(resultItem.CreatedDate > DateTime.MinValue);
            Assert.True(resultItem.LastModifiedDate > DateTime.MinValue);

            //Clean
            dbContext.Property.RemoveRange(dbContext.Property);
        }
        public void UpdatePropertySuccess()
        {
            //Arrange
            var propertyRepository = new PropertyRepository(_container);
            var dbContext          = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var properties         = TestDataRepository.GetProperties();

            foreach (var item in properties)
            {
                propertyRepository.CreateProperty(item);
            }
            var propertyToUpdate = propertyRepository.GetProperties().First();

            propertyToUpdate.Value = "Updated Value";

            //Act
            var result = propertyRepository.UpdateProperty(propertyToUpdate);

            //Assert
            Assert.NotNull(result);
            Assert.NotEqual(result.Id, Guid.Empty);
            Assert.True(!string.IsNullOrEmpty(result.Name));
            Assert.True(!string.IsNullOrEmpty(result.Label));
            Assert.True(propertyToUpdate.Value == result.Value);
            Assert.True(result.CreatedDate > DateTime.MinValue);
            Assert.True(result.LastModifiedDate > DateTime.MinValue);

            //Clean
            dbContext.Property.RemoveRange(dbContext.Property);
        }
Esempio n. 3
0
        public IEnumerable <Property> Get()
        {
            var service  = new PropertyRepository();
            var property = redis.Read <IEnumerable <Property> >("property", 0);

            if (property.Count() == 0)
            {
                return(service.GetProperties());
            }
            return(property);
        }
        public void GetPropertiesFail()
        {
            //Arrange
            var propertyRepository = new PropertyRepository(_container);
            var dbContext          = _serviceProvider.GetRequiredService <DeviserDbContext>();

            dbContext.Property.RemoveRange(dbContext.Property);

            //Act
            var result = propertyRepository.GetProperties();

            //Assert
            Assert.NotNull(result);
            Assert.True(result.Count == 0);

            //Clean
            dbContext.Property.RemoveRange(dbContext.Property);
        }