public void Test1() { string storageAccount = "janonostorage"; string storageKey = System.Environment.GetEnvironmentVariable("storageKey"); var osNameAndVersion = "";// System.Runtime.InteropServices.RuntimeInformation.OSDescription; string tableName = "testTableNetF" + osNameAndVersion; var setting = new AzureTableSettings(storageAccount, storageKey, tableName); var stor = new AzureTableStorage <TestContract>( new AzureTableSettings( storageAccount: storageAccount, storageKey: storageKey, tableName: tableName)); List <TestContract> listtest = new List <TestContract>(); for (int i = 0; i < 20000; i++) { var t = new TestContract(); t.PartitionKey = "_"; t.RowKey = i.ToString(); listtest.Add(t); } stor.GetTableAsyncCreateIfNotExistsAsync().GetAwaiter().GetResult(); stor.InsertReplace(listtest).GetAwaiter().GetResult(); stor.DeleteIfExistsAsync(); }
///<summary> ///</summary> public override List <VariationItem> Generate() { List <VariationItem> list = new List <VariationItem>(); // // Get combinations -- each item should be a VariationItemGroup. // List <VariationItem> groups = base.Generate(); // // Multiply each combination by the app types. // foreach (ContentItem appType in _applicationTypes) { TestContract defaultContract = new TestContract(); string appTypeStr = (string)appType.Content; // If the apptype is a deployed application, add the prebuilt // app to default SupportFiles. if (String.Equals(appTypeStr, "WpfApplication", StringComparison.InvariantCultureIgnoreCase)) { defaultContract.SupportFiles.Add("Common\\ControllerWpfApp.*"); } else if (String.Equals(appTypeStr, "Xbap", StringComparison.InvariantCultureIgnoreCase)) { defaultContract.SupportFiles.Add("Common\\ControllerBrowserApp.*"); } foreach (VariationItem item in groups) { ContainerVariationItem cvi = new ContainerVariationItem(); cvi.Title = appTypeStr; cvi.Creator = typeof(ContainerVariationGenerator).Name; cvi.ApplicationType = appTypeStr; cvi.Merge(this); cvi.Merge(defaultContract); cvi.Merge(item); cvi.Merge(appType); if (item is VariationItemGroup) { cvi.Children.AddRange(((VariationItemGroup)item).Children); } else { cvi.Children.Add(item); } list.Add(cvi); } } return(list); }
public void TestDataShapingForObjectResponse() { TestApiController testController = new TestApiController(); TestContract contract = new TestContract("1", "name", "description"); testController.RequiredFields = new List<string>(); testController.RequiredFields.Add("Name"); var processedResponse = testController.TestProcessResponse<TestContract>(contract) as IDictionary<string, object>; Assert.IsFalse(processedResponse.ContainsKey("ID")); Assert.AreEqual(processedResponse["Name"], "name"); Assert.IsFalse(processedResponse.ContainsKey("Description")); }
///<summary> ///</summary> public override List <VariationItem> Generate() { List <VariationItem> viList = new List <VariationItem>(ContentItems.Count); foreach (ContentItem ci in ContentItems) { string xtcFileName = (string)ci.Content; TestContract defaultContract = new TestContract(); defaultContract.SupportFiles.Add(xtcFileName); XmlDocument doc = new XmlDocument(); doc.Load(TestExtenderHelper.QualifyPath(xtcFileName)); // Construct the XmlNamespaceManager used for xpath queries later. NameTable ntable = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(ntable); nsmgr.AddNamespace("x", doc.DocumentElement.NamespaceURI); // Query for all TEST nodes. XmlNodeList testNodes = doc.SelectNodes("//x:TEST", nsmgr); // Set each TEST node in new CallbackVariationItem. foreach (XmlNode testNode in testNodes) { CallbackVariationItem cvi = new CallbackVariationItem(); cvi.Creator = "CallbackVariationGenerator"; cvi.MethodName = this.Callback; ContentItem contentItem = new ContentItem(); contentItem.Content = testNode.OuterXml; cvi.Content = contentItem; if (testNode.Attributes["Title"] != null) { cvi.Title = testNode.Attributes["Title"].Value as string; } cvi.Merge(this); cvi.Merge(defaultContract); cvi.Merge(ci); viList.Add(cvi); } } return(viList); }
public ActionResult Test() { //EFContext context = new EFContext(); //Blog_TestTable a = new Blog_TestTable(); //a.Name = "Lay"; //a.PassWord = "******"; //context.Blog_TestTables.Add(a); //context.SaveChanges(); ////Console.WriteLine("ok"); //string s = TestContract.CodeTest(); Class1 s = new Class1(); s.hello(); var test = TestContract.CodeTest(); return(test.ToMvcJson()); }
public void ReassignShouldWorksWell() { // GIVEN IoCContainer container = new IoCContainer(); // WHEN TestContractFirst objFirst = new TestContractFirst(); TestContractSecond objSecond = new TestContractSecond(); container.RegisterSingle <TestContract>(objFirst); Action reassign = () => container.RegisterSingle <TestContract>(objSecond, true); TestContract result = null; Action get = () => result = container.Get <TestContract>(); // THEN reassign.ShouldNotThrow(); get.ShouldNotThrow(); result.Should().Be(objSecond); }
public ContractTests() { var internalTxExecutor = new Mock <IInternalTransactionExecutor>(); var internalHashHelper = new Mock <IInternalHashHelper>(); var persistentState = new Mock <IPersistentState>(); var block = new Mock <IBlock>(); var message = new Mock <IMessage>(); Func <ulong> getBalance = () => 1; this.state = Mock.Of <ISmartContractState>( g => g.InternalTransactionExecutor == internalTxExecutor.Object && g.InternalHashHelper == internalHashHelper.Object && g.PersistentState == persistentState.Object && g.Block == block.Object && g.Message == message.Object && g.GetBalance == getBalance); this.type = typeof(TestContract); this.address = uint160.One; this.contract = Contract.CreateUninitialized(this.type, this.state, this.address); this.instance = (TestContract)this.contract.GetPrivateFieldValue("instance"); }
public void Test_Format_Complex_Object() { var nested1 = new NestedTestContract { X = "xxx", Y = 666, Z = new DateTime(2099, 01, 01) }; var nested2 = new NestedTestContract { X = "yyy", Y = 777, Z = new DateTime(9999, 01, 01) }; var testContract = new TestContract { A = "aaa", B = 42, C = new DateTime(2016, 02, 10), D = 36.6m, Nested = nested1, Array = new[] { nested1, nested2 }, List = new List <NestedTestContract> { nested1, nested2 }, Dictionary = new Dictionary <string, NestedTestContract> { { "item1", nested1 }, { "item2", nested2 } } }; var nestedFields = ResponseSpecification.Field("X").Field("Z"); var responseSpecification = ResponseSpecification .Field("A") .Field("D") .Field("C") .Field("Array", _ => _ .Field("X") .Field("Z") ) .Field("List", _ => _ .Field("X") .Field("Z") ) .Field("Nested", _ => nestedFields) .Field("Dictionary", _ => nestedFields); var actual = formatter.Format(testContract, responseSpecification); var nestedExpected1 = new { X = "xxx", Z = new DateTime(2099, 01, 01) }; var nestedExpected2 = new { X = "yyy", Z = new DateTime(9999, 01, 01) }; var expected = new { A = "aaa", D = 36.6, C = new DateTime(2016, 02, 10), Array = new[] { nestedExpected1, nestedExpected2, }, List = new[] { nestedExpected1, nestedExpected2, }, Nested = nestedExpected1, Dictionary = new { item1 = nestedExpected1, item2 = nestedExpected2 } }; AssertExpectedContract(actual, expected); }
public When_message_posted_as_Json() { contract = new Fixture().Create<TestContract>(); sut = new JsonContractInstance(JsonConvert.SerializeObject(contract)); }
public string Call(TestContract data1, TestContract data2) { return("Response " + data1.Text + " - " + data2.Text); }
public ActionResult Test02() { TestContract.Test(); return(Content("end")); }