private static int ThreadTestHelper(int userId) { var mockAdapter = new XmlMockAdapter( @"<Root><Users _keys=""Id"" Id=""System.Int32"" Key=""System.Guid""> <User Id=""" + userId + @""" Email=""foo"" Password=""bar""/> </Users></Root>"); MockHelper.UseMockAdapter(mockAdapter); return Database.Default.Users.FindByEmail("foo").Id; }
private static int ThreadTestHelper(int userId) { var mockAdapter = new XmlMockAdapter( @"<Root><Users _keys=""Id"" Id=""System.Int32"" Key=""System.Guid""> <User Id=""" + userId + @""" Email=""foo"" Password=""bar""/> </Users></Root>"); MockHelper.UseMockAdapter(mockAdapter); return(Database.Default.Users.FindByEmail("foo").Id); }
public void MyTestInitialize() { _mockAdapter = new XmlMockAdapter( @"<Root><Users _keys=""Id"" Id=""System.Int32"" Key=""System.Guid""> <User Id=""1"" Email=""foo"" Password=""bar"" Key=""4A1c8a8a-238d-443e-8ab2-bdf046a91fd7""> <Pets><Pet Name=""Fido""/></Pets> </User> <User Id=""2"" Email=""bar"" Password=""quux""/> <User Id=""3"" Email=""baz"" Password=""quux""/> <User Id=""4"" Email=""baz"" Password=""quux""/> </Users></Root>"); MockHelper.UseMockAdapter(_mockAdapter); }
public void FindByUrlId_ShouldFindRecord() { var adapter = new XmlMockAdapter(@"<Root> <Urls _keys=""UrlId"" UrlId=""System.Int32"" > <Url UrlId=""1"" LongUrl=""http://www.somesite.tld/"" Hash=""Hm5zT89z""/> </Urls> </Root>"); dynamic db = new Database(adapter); var url = db.Urls.FindByUrlId(1); Assert.IsNotNull(url); Assert.AreEqual("http://www.somesite.tld/", url.LongUrl); Assert.AreEqual("Hm5zT89z", url.Hash); }
public void FindBy_WithNonMatchingSecondValue_ShouldNotFind() { var adapter = new XmlMockAdapter( @"<root> <Users> <User Email=""someUser"" Password=""PASSWORD"" UserType=""AccountExecutive""/> </Users> <CustomerData SiteNo=""System.Int32"" CustomerNo=""System.Int32""> <Customer SiteNo=""500"" CustomerNo=""1"" SiteName=""Trump Towers"" EmailCust=""customerEmail"" AccountManagerEmail=""someOtherAccountExecutive""/> </CustomerData> </root>"); dynamic db = new Database(adapter); var customer = db.CustomerData.FindByCustomerNoAndAccountManagerEmail(1, "someEmail"); Assert.IsNull(customer); }
public void FindWithJoinInCriteriaSHouldWork() { var adapter = new XmlMockAdapter(@"<root><Users UserKey=""System.Guid"" UserCustomers=""UserCustomers""> <User Email=""somesiteUser"" Password=""PASSWORD"" UserType=""Customer"" UserKey=""FF47BE0F-A6AE-4B52-B7CC-B2F3CA413838""> <UserCustomers UserKey=""System.Guid"" CustomerNo=""System.Int32"" SiteNo=""System.Int32""> <UserCustomer UserKey=""FF47BE0F-A6AE-4B52-B7CC-B2F3CA413838"" CustomerNo=""1000"" SiteNo=""501""/> </UserCustomers> </User> </Users></root>"); dynamic db = new Database(adapter); var associatedUser = db.Users.Find(db.Users.UserCustomers.CustomerNo == 1000 && db.Users.UserType == "Customer"); Assert.IsNotNull(associatedUser); Assert.AreEqual(new Guid("FF47BE0F-A6AE-4B52-B7CC-B2F3CA413838"), associatedUser.UserKey); }