public void Constructor() { var dutchBelgium = new Locales(this.Session).DutchBelgium; new C1Builder(this.Session).WithC1AllorsString("c1A").WithC1C2One2One(new C2Builder(this.Session).WithC2AllorsString("c2A").Build()).Build(); new C1Builder(this.Session).WithC1AllorsString("c1B").WithC1C2One2One(new C2Builder(this.Session).WithC2AllorsString("c2B").Build()).Build(); this.Session.Derive(true); var aclMock = new Mock <IAccessControlList>(); aclMock.Setup(acl => acl.CanRead(It.IsAny <PropertyType>())).Returns(true); var acls = new AccessControlListCache(null, (allorsObject, user) => aclMock.Object); var export = new CsvExport("Test"); export.Columns.Add(new CsvExportPath(M.C1.C1AllorsString)); export.Columns.Add(new CsvExportFunction <C1>("Function", (c1, aclFactory) => CsvExport.Escape("Hello " + c1.C1AllorsString))); var extent = this.Session.Extent(M.C1.ObjectType).AddSort(M.C1.C1AllorsString); var csv = export.Write(extent, dutchBelgium, acls); Assert.AreEqual( @"""C1AllorsString"";""Function"" ""c1A"";""Hello c1A"" ""c1B"";""Hello c1B""".Replace("\r\n", "\n"), csv.Replace("\r\n", "\n")); }
public void One2ManyWithPropertyNames() { var c2A = new C2Builder(this.Session).WithC2AllorsString("c2A").Build(); var c2B = new C2Builder(this.Session).WithC2AllorsString("c2B").Build(); var c2C = new C2Builder(this.Session).WithC2AllorsString("c2C").Build(); var c1A = new C1Builder(this.Session) .WithC1AllorsString("c1A") .WithC1C2One2Many(c2A) .Build(); var c1B = new C1Builder(this.Session) .WithC1AllorsString("c1B") .WithC1C2One2Many(c2B) .WithC1C2One2Many(c2C) .Build(); this.Session.Derive(true); Path path; Path.TryParse(M.C2.ObjectType, "C1WhereC1C2One2Many", out path); var aclMock = new Mock <IAccessControlList>(); aclMock.Setup(acl => acl.CanRead(It.IsAny <PropertyType>())).Returns(true); var acls = new AccessControlListCache(null, (allorsObject, user) => aclMock.Object); var result = (C1)path.Get(c2A, acls); Assert.AreEqual(result, c1A); result = (C1)path.Get(c2B, acls); Assert.AreEqual(result, c1B); }
public void Locale() { var englishGreatBritain = new Locales(this.Session).EnglishGreatBritain; var dutchBelgium = new Locales(this.Session).DutchBelgium; new C1Builder(this.Session).WithC1AllorsString("c1A").WithC1AllorsDecimal(10.5M).Build(); new C1Builder(this.Session).WithC1AllorsString("c1B").WithC1AllorsDecimal(11.5M).Build(); this.Session.Derive(true); var column1 = new CsvExportPath(M.C1.C1AllorsString); var column2 = new CsvExportPath(M.C1.C1AllorsDecimal); var export = new CsvExport("Test"); export.Columns.Add(column1); export.Columns.Add(column2); var extent = this.Session.Extent(M.C1.ObjectType).AddSort(M.C1.C1AllorsString); var user = new Users(this.Session).GetCurrentUser(); var acls = new AccessControlListCache(user); var csvEn = export.Write(extent, englishGreatBritain, acls); var csvNl = export.Write(extent, dutchBelgium, acls); Assert.AreNotEqual(csvEn, csvNl); }
public void OperandTypeConstructor() { var dutchBelgium = new Locales(this.Session).DutchBelgium; new C1Builder(this.Session).WithC1AllorsString("c1A").WithC1AllorsDecimal(10.5M).Build(); new C1Builder(this.Session).WithC1AllorsString("c1B").WithC1AllorsDecimal(11.5M).Build(); this.Session.Derive(true); var csvFile = new CsvExport("Test"); csvFile.Columns.Add(new CsvExportPath(M.C1.C1AllorsString)); csvFile.Columns.Add(new CsvExportPath(M.C1.C1AllorsDecimal)); var aclMock = new Mock <IAccessControlList>(); aclMock.Setup(acl => acl.CanRead(It.IsAny <PropertyType>())).Returns(true); var acls = new AccessControlListCache(null, (allorsObject, user) => aclMock.Object); var extent = this.Session.Extent(M.C1.ObjectType).AddSort(M.C1.C1AllorsString); var csv = csvFile.Write(extent, dutchBelgium, acls); Assert.AreEqual( @"""C1AllorsString"";""C1AllorsDecimal"" ""c1A"";""10,5"" ""c1B"";""11,5""".Replace("\r\n", "\n"), csv.Replace("\r\n", "\n")); }
public void Locale() { var englishGreatBritain = new Locales(this.Session).EnglishGreatBritain; var dutchBelgium = new Locales(this.Session).DutchBelgium; new C1Builder(this.Session).WithC1AllorsString("c1A").WithC1AllorsDecimal(10.5M).Build(); new C1Builder(this.Session).WithC1AllorsString("c1B").WithC1AllorsDecimal(11.5M).Build(); this.Session.Derive(true); var csvFile = new CsvExport("Test"); csvFile.Columns.Add(new CsvExportPath(M.C1.C1AllorsString)); csvFile.Columns.Add(new CsvExportFunction <C1>( "Function", (c1, acl, cultureInfo) => { if (c1.C1AllorsDecimal.HasValue) { return(CsvExport.Escape(c1.C1AllorsDecimal.Value.ToString(cultureInfo))); } return(string.Empty); })); var extent = this.Session.Extent(M.C1.ObjectType).AddSort(M.C1.C1AllorsString); var aclMock = new Mock <IAccessControlList>(); aclMock.Setup(acl => acl.CanRead(It.IsAny <PropertyType>())).Returns(true); var acls = new AccessControlListCache(null, (allorsObject, user) => aclMock.Object); var csvEn = csvFile.Write(extent, englishGreatBritain, acls); var csvNl = csvFile.Write(extent, dutchBelgium, acls); Assert.AreNotEqual(csvEn, csvNl); Assert.AreEqual( @"""C1AllorsString"";""Function"" ""c1A"";""10,5"" ""c1B"";""11,5""".Replace("\r\n", "\n"), csvNl.Replace("\r\n", "\n")); Assert.AreEqual( @"""C1AllorsString"",""Function"" ""c1A"",""10.5"" ""c1B"",""11.5""".Replace("\r\n", "\n"), csvEn.Replace("\r\n", "\n")); }
public void One2ManyWithPropertyTypeIds() { var c2A = new C2Builder(this.Session).WithC2AllorsString("c2A").Build(); var c2B = new C2Builder(this.Session).WithC2AllorsString("c2B").Build(); var c2C = new C2Builder(this.Session).WithC2AllorsString("c2C").Build(); var c1a = new C1Builder(this.Session) .WithC1AllorsString("c1A") .WithC1C2One2Many(c2A) .Build(); var c1b = new C1Builder(this.Session) .WithC1AllorsString("c1B") .WithC1C2One2Many(c2B) .WithC1C2One2Many(c2C) .Build(); this.Session.Derive(true); var path = new Path(MetaC1.Instance.C1C2One2Manies, MetaC2.Instance.C2AllorsString); var aclMock = new Mock <IAccessControlList>(); aclMock.Setup(acl => acl.CanRead(It.IsAny <PropertyType>())).Returns(true); var acls = new AccessControlListCache(null, (allorsObject, user) => aclMock.Object); var result = (ISet <object>)path.Get(c1a, acls); Assert.AreEqual(1, result.Count); Assert.IsTrue(result.Contains("c2A")); result = (ISet <object>)path.Get(c1b, acls); Assert.AreEqual(2, result.Count); Assert.IsTrue(result.Contains("c2B")); Assert.IsTrue(result.Contains("c2C")); }