Ejemplo n.º 1
0
        private static void ImportFromJsonFile(string jsonFileName)
        {
            var dbContext            = new ApplicationDbContext();
            IPropertyService service = new PropertyService(dbContext);
            var properties           = JsonSerializer.Deserialize <IEnumerable <PropertyAsJson> >(File.ReadAllText(jsonFileName));

            foreach (var jsonProp in properties)
            {
                service.Add(jsonProp.Size, jsonProp.YardSize, jsonProp.Floor, jsonProp.TotalFloors, jsonProp.District, jsonProp.Year, jsonProp.Type, jsonProp.BuildingType, jsonProp.Price);
                Console.WriteLine(".");
            }
        }
Ejemplo n.º 2
0
        public void ShouldBeAbleToGetAllPropertiesWithPrefix()
        {
            // Arrange
            PropertyService service = new PropertyService();

            service.Add(new Property {
                Key = "myProperty.value1", Value = "value1"
            });
            service.Add(new Property {
                Key = "myProperty.value2", Value = "value2"
            });
            service.Add(new Property {
                Key = "someOtherProperty.value1", Value = "value3"
            });

            // Act
            var properties = service.StartingWith("myProperty");

            // Assert
            Assert.Equal(2, properties.Count());
            Assert.Equal("value1", properties.Where(p => p.Key == "myProperty.value1").Single().Value);
            Assert.Equal("value2", properties.Where(p => p.Key == "myProperty.value2").Single().Value);
        }
Ejemplo n.º 3
0
        public void ShouldReturnNullIfPropertyIsNotAnInt()
        {
            // Arrange
            var service = new PropertyService();

            service.Add(new Property {
                Key = "myProperty", Value = "abcd"
            });

            // Act
            var value = service.GetInt("myProperty");

            // Assert
            Assert.Null(value);
        }
Ejemplo n.º 4
0
        public void ShouldBeAbleToGetPropertyFromIndexer()
        {
            // Arrange
            PropertyService service = new PropertyService();

            service.Add(new Property {
                Key = "myProperty", Value = "myValue"
            });

            // Act
            var propertyValue = service["myProperty"];

            // Assert
            Assert.Equal("myValue", propertyValue.Value);
        }
Ejemplo n.º 5
0
        public void ShouldBeAbleToReturnPropertyAsInt()
        {
            // Arrange
            var service = new PropertyService();

            service.Add(new Property {
                Key = "myProperty", Value = "100"
            });

            // Act
            var value = service.GetInt("myProperty");

            // Assert
            Assert.Equal(100, value);
        }