public void ExpressionGenerator_DbBinaryExpression() { { var _ = new TestModel(); var column1 = _.Column1; var column2 = _.Column2; VerifyDbExpression(MySqlVersion.LowestSupported, (column1 + column2).DbExpression, "(`TestModel`.`Column1` + `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 - column2).DbExpression, "(`TestModel`.`Column1` - `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 * column2).DbExpression, "(`TestModel`.`Column1` * `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 / column2).DbExpression, "(`TestModel`.`Column1` / `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 % column2).DbExpression, "(`TestModel`.`Column1` % `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 == column2).DbExpression, "(`TestModel`.`Column1` = `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 != column2).DbExpression, "(`TestModel`.`Column1` <> `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 > column2).DbExpression, "(`TestModel`.`Column1` > `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 >= column2).DbExpression, "(`TestModel`.`Column1` >= `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 < column2).DbExpression, "(`TestModel`.`Column1` < `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 <= column2).DbExpression, "(`TestModel`.`Column1` <= `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 & column2).DbExpression, "(`TestModel`.`Column1` & `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 | column2).DbExpression, "(`TestModel`.`Column1` | `TestModel`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (column1 ^ column2).DbExpression, "(`TestModel`.`Column1` ^ `TestModel`.`Column2`)"); } { var _ = new TestModel2(); var boolColumn1 = _.Column1; var boolColumn2 = _.Column2; VerifyDbExpression(MySqlVersion.LowestSupported, (boolColumn1 & boolColumn2).DbExpression, "(`TestModel2`.`Column1` AND `TestModel2`.`Column2`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (boolColumn1 | boolColumn2).DbExpression, "(`TestModel2`.`Column1` OR `TestModel2`.`Column2`)"); } }
public void ReadValue_reads_Id_field() { var testModel = new TestModel2 { Id = 5 }; var id = IdReader.ReadValue(testModel); id.Should().Be(testModel.Id); }
public void TestComplexConverting() { var testObject = new TestModel2(); testObject.Parent = new TestModel2(); var converter = new BinaryConverter.models.BinaryConverter(); var bytes = converter.Encode(testObject); TestModel2 decoded = (TestModel2)converter.Decode(bytes.ToArray()); Assert.IsTrue(decoded.Validate(testObject)); }
public void TestAutoCopyJobj() { var model1 = new TestModel2 { Age = 10, Name = "sadfasd", Page = 123333333333333333, Man = false }; var json = @"{""age"":9,""name"":""json数据"",""man"":true}"; var josnObj = JObject.Parse(json); var result = model1.JsonCopy(josnObj, StringFormatEnum.Up); Console.WriteLine($"测试结果:{result.ToString()}"); Assert.True(!result.ToString().Contains(" ")); }
public void Equals_ReturnsFalse_WhenMemberIsAccessedThroughConstantExpression() { // Arrange var testModel = new TestModel2 { Id = 1 }; var key1 = GetKey(m => testModel.Id); var key2 = GetKey <TestModel2, int>(m => m.Id); // Act VerifyNotEquals(key1, key2); }
public void TestTsdbTagPrettify() { var model1 = new TestModel2 { Age = 10, Name = "sadfasd", Page = 123333333333333333 }; var model2 = new TestModel2 { Age = 101, Name = "sadfasd1", Page = 4444444444444 }; var result = model2.AutoCompare(model1); Console.WriteLine($"测试结果:{result.ToString()}"); Assert.True(!result.ToString().Contains(" ")); }
public void TestRecursiveLoop() { var testObject = new TestModel2(); testObject.Parent = testObject; var converter = new BinaryConverter.models.BinaryConverter(); try { converter.Encode(testObject); Assert.IsFalse(true, "An InfiniteEncodingLoopException should have been thrown"); // exception not thrown - error } catch (InfiniteEncodingLoopException e) { Assert.IsTrue(true, "InfiniteEncodingLoopException was thrown - as it should have been"); // exception thrown - as it should have been } }
public void ExpressionGenerator_DbUnaryExpression() { { var _ = new TestModel(); var int32Column = _.Column1; VerifyDbExpression(MySqlVersion.LowestSupported, (-int32Column).DbExpression, "(-`TestModel`.`Column1`)"); VerifyDbExpression(MySqlVersion.LowestSupported, (~int32Column).DbExpression, "(~`TestModel`.`Column1`)"); } { var _ = new TestModel2(); var boolColumn = _.Column1; VerifyDbExpression(MySqlVersion.LowestSupported, (!boolColumn).DbExpression, "(NOT `TestModel2`.`Column1`)"); } }
public void TestMethod1() { var model = new TestModel2 { Age = 10, Name = "sadfasd", Page = 123333333333333333 }; var model2 = new TestModel2 { Age = 10 }; var newModel = new TestModel1 { Age = 22, Name = "22222", Page = 222222222222222 }; var result = newModel.AutoCopy(model2); Console.WriteLine($"测试结果:{result.ToString()}"); Assert.True(result != null); }
public void FWSecureLongTest() { var model = new TestModel2() { Id = 10, Test = "Hello World!" }; var map1 = model.Map <TestModel>(); Assert.Equal(10, map1.Id.Value); Assert.Equal("Hello World!", map1.Test); var map2 = map1.Map <TestModel2>(); Assert.Equal(10, map2.Id); Assert.Equal("Hello World!", map2.Test); }
public void UnboundObjectTargetName() { var testObject1 = new TestModel1 { NotName = "TestObject1" }; var testObject2 = new TestModel2 { NotName = "TestObject1" }; var pso1 = PSObject.AsPSObject(testObject1); var pso2 = PSObject.AsPSObject(testObject2); PipelineContext.CurrentThread = PipelineContext.New(option: new PSRuleOption(), hostContext: null, binder: new TargetBinder(null, null, null, null), baseline: null, unresolved: null); var actual1 = PipelineHookActions.BindTargetName(null, false, pso1); var actual2 = PipelineHookActions.BindTargetName(null, false, pso2); Assert.Equal(expected: "f209c623345144be61087d91f30c17b01c6e86d2", actual: actual1); Assert.Equal(expected: "f209c623345144be61087d91f30c17b01c6e86d2", actual: actual2); }
public async Task MultiUploadFileModelWithModel() { var model = new TestModel { Property = "test", Collection = new List <string>() { "test1", "test2" } }; var model2 = new TestModel2 { Property = "Model2Prop" }; var model22 = new TestModel2 { Property = "Model22Prop" }; model.ModelCollection = new List <TestModel2>() { model2, model22 }; var request = this.Fixture.Server.CreateApiRequest <ValuesController>(c => c.GetPaginatedModel(null)); var content = new MultipartFormDataContent(); var json = await this.serializer.SerializeAsync(model); var modelContent = new StringContent(json, Encoding.UTF8); content.Add(modelContent, "model"); request.And(message => { message.Content = content; }); var response = await request.SendAsync(HttpMethods.Post); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var data = await response.Content.ReadAsStringAsync(); Assert.Equal(json, data); }
public IHttpActionResult TestModel2(TestModel2 model) { return(OutputErrors()); }
public ActionResult Test2(TestModel2 test) { return(Content(test == null ? "null" : "not null")); }
public static IModelUI CreateForTestModel2(this ElementBuilder elementBuilder, CommandDispatcher commandDispatcher, TestModel2 model) { return(null); }
public string Workaround([FromQuery] TestModel2 model) { return("value"); }
public bool MyEquals(TestModel2 a) { return(IdStr == a.IdStr && NameInt == a.NameInt && ValueLong == a.ValueLong); }
public IHttpActionResult TestModel2(TestModel2 model) { return OutputErrors(); }
public string Reader(TestModel2 testModel) { return(""); }