protected object CoreGetService(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } object result = null; if (serviceType == typeof(IPackageRepository)) { result = this.CreatePackageRepository(); } else if (serviceType == typeof(IJsonSearlizer)) { result = new JsonNetSearlizer(); } // MVC controllers else if (serviceType == typeof(ConfigController)) { result = new ConfigController(this.CreatePackageRepository(), this.CreateJsonSearlizer()); } else if (serviceType == typeof(HomeController)) { result = new HomeController(this.CreatePackageRepository()); } // API Controllers else if (serviceType == typeof(ConfigController)) { result = new ConfigController(this.CreatePackageRepository(), this.CreateJsonSearlizer()); } else if (serviceType == typeof(HomeController)) { result = new HomeController(this.CreatePackageRepository()); } return result; }
public void Test_SearlizeToString() { IJsonSearlizer searlizer = new JsonNetSearlizer(); MSDeployDeploymentParameters msdParams = RandomDataHelper.Instance.CreateRandomMSDeployDeploymentParameters(); string result = searlizer.Searlize(msdParams); Assert.IsNotNull(result); Assert.IsTrue(result.Length > 1); }
public void TestJsonNetSearlizer_Searlize() { IJsonSearlizer searlizer = new JsonNetSearlizer(); TestClass tc = new TestClass { Id = RandomDataHelper.Instance.Primitives.GetRandomLong(int.MaxValue), FirstName = Guid.NewGuid().ToString(), LastName = Guid.NewGuid().ToString() }; string expectedString = string.Format( @"{{""Id"":{0},""FirstName"":""{1}"",""LastName"":""{2}""}}", tc.Id, tc.FirstName, tc.LastName); string actualString = searlizer.Searlize(tc); Assert.AreEqual(expectedString, actualString); }
public void TestJsonNetSearlizer_Desearlize_T() { TestClass expectedTc = new TestClass { Id = RandomDataHelper.Instance.Primitives.GetRandomLong(int.MaxValue), FirstName = Guid.NewGuid().ToString(), LastName = Guid.NewGuid().ToString() }; string actualTcAsString = string.Format( @"{{""Id"":{0},""FirstName"":""{1}"",""LastName"":""{2}""}}", expectedTc.Id, expectedTc.FirstName, expectedTc.LastName); IJsonSearlizer searlizer = new JsonNetSearlizer(); TestClass actualTc = searlizer.Desearlize<TestClass>(actualTcAsString); Assert.AreEqual(expectedTc, actualTc); }
public void Test_DesearlizeFromString() { IJsonSearlizer searlizer = new JsonNetSearlizer(); string iisAppParamName = @"IIS Web Application Name"; string iisAppParamValue = @"Default Web Site/FooBar"; string msdeployDeployParametersString = string.Format(@"{{ ""MsdeployTimeout"":""10000"", ""Parameters"" : {{ ""{0}"" : ""{1}"" }} }}", iisAppParamName, iisAppParamValue); MSDeployDeploymentParameters result = searlizer.Desearlize<MSDeployDeploymentParameters>(msdeployDeployParametersString); Assert.IsNotNull(result); Assert.IsNotNull(result.Parameters); Assert.AreEqual(1, result.Parameters.Count); Assert.AreEqual(10000, result.MsdeployTimeout); }