public void SerializesProperly(LocationConfiguration configuration)
        {
            var serialized = JsonConvert.SerializeObject(configuration);
            var json       = JObject.Parse(serialized);

            CompareJsonAndNetObject(json, configuration);
        }
        // Uncomment the method below to handle the event raised before a feature is deactivated.
        //public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        //{
        //}
        // Uncomment the method below to handle the event raised after a feature has been installed.
        //public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        //{
        //}
        // Uncomment the method below to handle the event raised before a feature is uninstalled.
        //public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        //{
        //}
        // Uncomment the method below to handle the event raised when a feature is upgrading.
        //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
        //{
        //}
        private LocationConfiguration GetFederatedLocation(string osdxPath)
        {
            var newLocation = new LocationConfiguration();
            using (var fs = new FileStream(osdxPath, FileMode.Open))
            {
                newLocation.Import(fs);
                newLocation.Update();
            }

            return newLocation;
        }
        public void Resolve()
        {
            var container = CreateContainer();
            var meConfig = new SimpleMappingEngineConfiguration(container);
            meConfig.Configure();

            var config = new LocationConfiguration(container);
            config.Configure();

            var validator = container.Resolve<IMapper<EnergyTrading.MDM.Contracts.Sample.Location, Location>>();

            // Assert
            Assert.IsNotNull(validator, "Mapper resolution failed");
        }
 public void CompareJsonAndNetObject(JObject json, LocationConfiguration configuration)
 {
     foreach (var propertyType in typeof(LocationConfiguration).GetProperties().Where(p => p.Name != "FulfillerId"))
     {
         var jsonName = Char.ToLower(propertyType.Name[0]) + propertyType.Name.Substring(1);
         Assert.Equal(propertyType.GetValue(configuration).ToString(), json.GetValue(jsonName).ToString());
     }
     if (configuration.FulfillerId.InternalFulfillerId.HasValue)
     {
         Assert.Equal(configuration.FulfillerId.InternalFulfillerId.Value, json.GetValue("fulfillerId"));
     }
     else
     {
         Assert.Equal(configuration.FulfillerId.FulfillerId, json.GetValue("fulfillerId").ToString());
     }
 }
        public async Task <FulfillmentLocation> CreateFulfillmentLocation(LocationConfiguration locationConfiguration)
        {
            var builder = new UriBuilder(_url);

            builder.Path += builder.Path.Last() == '/' ? _routes["fulfillmentLocations"].Substring(1) : _routes["fulfillmentLocations"];
            var request = new HttpRequestMessage()
            {
                RequestUri = builder.Uri,
                Method     = HttpMethod.Post,
                Headers    =
                {
                    { "Authorization", _GetAuthorization() },
                },
                Content = new StringContent(
                    JsonConvert.SerializeObject(locationConfiguration),
                    Encoding.UTF8,
                    "application/json")
            };
            var response = await _httpClient.SendAsync(request);

            if (response.StatusCode == HttpStatusCode.Forbidden)
            {
                throw new AccessForbiddenException();
            }
            if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                throw new InvalidConfigurationException();
            }
            else if (!response.IsSuccessStatusCode)
            {
                throw new CommunicationFailureException();
            }
            else
            {
                if (response.Content == null)
                {
                    return(null);
                }
                else
                {
                    var stringResponse = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <FulfillmentLocation>(stringResponse));
                }
            }
        }
Exemplo n.º 6
0
        public void ValidatorResolution()
        {
            var container = CreateContainer();
            var meConfig  = new SimpleMappingEngineConfiguration(container);

            meConfig.Configure();

            var repository = new Mock <IRepository>();

            container.RegisterInstance(repository.Object);

            var config = new LocationConfiguration(container);

            config.Configure();

            var validator = container.Resolve <IValidator <Location> >("location");

            // Assert
            Assert.IsNotNull(validator, "Validator resolution failed");
        }
        public void ValidatorResolution()
        {
            var container = CreateContainer();
            var meConfig = new SimpleMappingEngineConfiguration(container);
            meConfig.Configure();

            var repository = new Mock<IRepository>();
            container.RegisterInstance(repository.Object);

            var config = new LocationConfiguration(container);
            config.Configure();

            var validator = container.Resolve<IValidator<Location>>("location");

            // Assert
            Assert.IsNotNull(validator, "Validator resolution failed");
        }
 public async Task <FulfillmentLocation> UpdateFulfillmentLocation(int internalFulfillmentLocationId, LocationConfiguration locationConfiguration)
 {
     return(await _UpdateFulfillmentLocation(internalFulfillmentLocationId.ToString(), locationConfiguration));
 }
 public async Task <FulfillmentLocation> UpdateFulfillmentLocation(string fulfillmentLocationId, LocationConfiguration locationConfiguration)
 {
     return(await _UpdateFulfillmentLocation(fulfillmentLocationId, locationConfiguration));
 }