public void DecectsDateDelta_WhenDateIsStringFormat() { var originalCustomer = new TestCustomer { FirstName = "originalFirstName", Age = 20, DateOfBirth = new DateTime(1940, 2, 3) }; var newCustomer = new { FirstName = "newFirstName", Age = 20, DateOfBirth = "December 8, 1979" }; var newCustomerJObj = JObject.FromObject(newCustomer); var deltaGroup = DeltaObjectFromJObjectGenerator.GetDeltaObjects(originalCustomer, newCustomerJObj); Assert.NotNull(deltaGroup); Assert.Equal(2, deltaGroup.DeltaObjects.Count); Assert.Empty(deltaGroup.DeltaObjectsValueConversionFail); Assert.Equal(GroupValueConversionStatus.NoneFailed, deltaGroup.ValueConversionStatus); Assert.Equal(ValueConversionStatus.Success, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.FirstName)).ValueConversionStatus); Assert.Equal(ValueConversionStatus.Success, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.DateOfBirth)).ValueConversionStatus); Assert.Equal(newCustomer.FirstName, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.FirstName)).NewValue); Assert.Equal(new DateTime(1979, 12, 8), deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.DateOfBirth)).NewValue); }
public void Remote() { using (var store = NewRemoteDocumentStore()) { { var customer = new TestCustomer { Id = "LoremipsumdolorsitametconsecteturadipiscingelitPraesentlobortisconguecursusCurabiturconvallisnuncmattisliberomolestieidiaculismagnaimperdietDuisnecenimsednislvestibulumvulputateDonecnuncarcumolestieeutinciduntacfermentumpretiumestAeneannoncondimentumorciDonecsitametanteerossedgravidaestQuisqueturpismaurisplaceratsedaliquamidgravidasednislIntegermetusleoultriciesegetiaculisnonporttitornonlacusProinegetfringillalectusCrasfeugiatloremaauctoregestasmienimpulvinarsemquisbibendumloremvelitnonnullaDonecultriciesfelissednunctinciduntutrutrumtellusmolestieIntegerliberorisusvariusinvehiculaidtristiqueidarcNuncpretiummolestieduicongueauctorloremcursussitametCurabituridmassaeratcursusadipiscingvelitNullaminmaurisestsitametpretiumnislSedmollisultriciespurusNuncaerosnislnonmollislacusIntegerlaciniavariuscommodoNamrutrumerossitametni" }; using (IDocumentSession session = store.OpenSession()) { session.Store(customer); session.SaveChanges(); } // This works using (var session = store.OpenSession()) { IEnumerable<TestCustomer> actual = session.Query<TestCustomer>() .Customize(x => x.WaitForNonStaleResults()).ToArray(); Assert.Equal(customer.Id, actual.Single().Id); } // This fails with invalid operation exception using (IDocumentSession session = store.OpenSession()) { var loadedCustomer = session.Load<TestCustomer>(customer.Id); Assert.NotNull(loadedCustomer); } } } }
public void Can_check_whether_customer_is_forum_moderator() { var customer = new TestCustomer(); customer.CustomerRoles.Add(new CustomerRole { Active = true, Name = "Registered", SystemName = NopCustomerDefaults.RegisteredRoleName }); customer.CustomerRoles.Add(new CustomerRole { Active = true, Name = "Guests", SystemName = NopCustomerDefaults.GuestsRoleName }); customer.IsForumModerator().ShouldBeFalse(); customer.CustomerRoles.Add( new CustomerRole { Active = true, Name = "ForumModerators", SystemName = NopCustomerDefaults.ForumModeratorsRoleName }); customer.IsForumModerator().ShouldBeTrue(); }
public void GetValues_WhenDeepGraphWithEnumerables_CanExtractValues() { var prodNoProperty = StructurePropertyTestFactory.GetPropertyByPath <TestCustomer>("Orders.Lines.ProductNo"); var pricesProperty = StructurePropertyTestFactory.GetPropertyByPath <TestCustomer>("Orders.Lines.Prices"); var graph = new TestCustomer { Orders = { new TestOrder { Lines = { new TestOrderLine { ProductNo = "P1", Quantity = 1, Prices = new[]{ 42, 4242 } }, new TestOrderLine { ProductNo = "P2", Quantity = 2, Prices = new[]{ 43, 4343 } } } } } }; var productNos = IndexAccessorTestFactory.CreateFor(prodNoProperty).GetValues(graph); var prices = IndexAccessorTestFactory.CreateFor(pricesProperty).GetValues(graph); CollectionAssert.AreEqual(new[] { "P1", "P2" }, productNos.Select(i => i.Value).ToArray()); CollectionAssert.AreEqual(new[] { 42, 4242, 43, 4343 }, prices.Select(i => i.Value).ToArray()); }
public void Remote() { using (var store = GetDocumentStore()) { var customer = new TestCustomer { Id = "LoremipsumdolorsitametconsecteturadipiscingelitPraesentlobortisconguecursusCurabiturconvallisnuncmattisliberomolestieidiaculismagnaimperdietDuisnecenimsednislvestibulumvulputateDonecnuncarcumolestieeutinciduntacfermentumpretiumestAeneannoncondimentumorciDonecsitametanteerossedgravidaestQuisqueturpismaurisplaceratsedaliquamidgravidasednislIntegermetusleoultriciesegetiaculisnonporttitornonlacusProinegetfringillalectusCrasfeugiatloremaauctoregestasmienimpulvinarsemquisbibendumloremvelitnonnullaDonecultriciesfe" }; using (IDocumentSession session = store.OpenSession()) { session.Store(customer); session.SaveChanges(); } // This works using (var session = store.OpenSession()) { IEnumerable <TestCustomer> actual = session.Query <TestCustomer>() .Customize(x => x.WaitForNonStaleResults()).ToArray(); Assert.Equal(customer.Id, actual.Single().Id); } // This fails with invalid operation exception using (IDocumentSession session = store.OpenSession()) { var loadedCustomer = session.Load <TestCustomer>(customer.Id); Assert.NotNull(loadedCustomer); } } }
public void ThrowsArgumentNullException_WhenSecondArgNull() { var originalCustomer = new TestCustomer(); Assert.Throws <ArgumentNullException>(() => originalCustomer.GetDeltaObjects((JObject)null)); }
public void GetValues_WhenDeepGraphWithEnumerables_CanExtractValues() { var prodNoProperty = StructurePropertyTestFactory.GetPropertyByPath<TestCustomer>("Orders.Lines.ProductNo"); var pricesProperty = StructurePropertyTestFactory.GetPropertyByPath<TestCustomer>("Orders.Lines.Prices"); var graph = new TestCustomer { Orders = { new TestOrder { Lines = { new TestOrderLine { ProductNo = "P1", Quantity = 1, Prices = new[] { 42, 4242 }}, new TestOrderLine { ProductNo = "P2", Quantity = 2, Prices = new[] { 43, 4343 }} } } } }; var productNos = IndexAccessorTestFactory.CreateFor(prodNoProperty).GetValues(graph); var prices = IndexAccessorTestFactory.CreateFor(pricesProperty).GetValues(graph); CollectionAssert.AreEqual(new[] { "P1", "P2" }, productNos); CollectionAssert.AreEqual(new[] { 42, 4242, 43, 4343 }, prices); }
public void ReturnsDeltaObjects_WhenCalled() { var originalCustomer = new TestCustomer { FirstName = "originalFirstName", LastName = "originalLastName" }; var newCustomer = new { FirstName = "newFirstName", LastName = "originalLastName" }; var newCustomerJObj = JObject.FromObject(newCustomer); var sut = new DeltaObjectEngine(); var deltaGroup = sut.GetDeltaObjects(originalCustomer, newCustomerJObj); Assert.NotNull(deltaGroup); Assert.Equal(GroupValueConversionStatus.NoneFailed, deltaGroup.ValueConversionStatus); Assert.Single(deltaGroup.DeltaObjects); Assert.Empty(deltaGroup.DeltaObjectsValueConversionFail); Assert.Equal(ValueConversionStatus.Success, deltaGroup.DeltaObjects[0].ValueConversionStatus); Assert.Equal(newCustomer.FirstName, deltaGroup.DeltaObjects[0].NewValue); }
public void GetValues_WhenDeepGraphWithEnumerables_CanExtractValues() { var ordersPropertyInfo = typeof(TestCustomer).GetProperty("Orders"); var ordersProperty = new Property(ordersPropertyInfo); var linesPropertyInfo = typeof(TestOrder).GetProperty("Lines"); var linesProperty = new Property(1, ordersProperty, linesPropertyInfo); var prodNoPropertyInfo = typeof(TestOrderLine).GetProperty("ProductNo"); var prodNoProperty = new Property(2, linesProperty, prodNoPropertyInfo); var graph = new TestCustomer { Orders = { new TestOrder { Lines = { new TestOrderLine { ProductNo = "P1", Quantity = 1 }, new TestOrderLine { ProductNo = "P2", Quantity = 2 } } } } }; var values = prodNoProperty.GetValues(graph); CollectionAssert.AreEqual(new[] { "P1", "P2" }, values); }
public void ReturnsDeltaWithInvalidConversionStatus_WhenCannotConvertDate() { var originalCustomer = new TestCustomer { FirstName = "originalFirstName", Age = 20, DateOfBirth = new DateTime(1940, 2, 3) }; var newCustomer = new { FirstName = "newFirstName", Age = 20, DateOfBirth = "some long ago era" }; var newCustomerJObj = JObject.FromObject(newCustomer); var deltaGroup = DeltaObjectFromJObjectGenerator.GetDeltaObjects(originalCustomer, newCustomerJObj); Assert.NotNull(deltaGroup); Assert.Equal(GroupValueConversionStatus.SomeFailed, deltaGroup.ValueConversionStatus); Assert.Single(deltaGroup.DeltaObjects); Assert.Single(deltaGroup.DeltaObjectsValueConversionFail); Assert.Equal(ValueConversionStatus.Success, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.FirstName)).ValueConversionStatus); Assert.Equal(ValueConversionStatus.Fail, deltaGroup.DeltaObjectsValueConversionFail.First(o => o.PropertyName == nameof(TestCustomer.DateOfBirth)).ValueConversionStatus); Assert.Equal(newCustomer.FirstName, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.FirstName)).NewValue); Assert.Equal(newCustomer.DateOfBirth, deltaGroup.DeltaObjectsValueConversionFail.First(o => o.PropertyName == nameof(TestCustomer.DateOfBirth)).NewValue); }
public virtual void OnAppStartup() { using (IDependencyResolver childDependencyResolver = _dependencyManager.CreateChildDependencyResolver()) { TestDbContext dbContext = childDependencyResolver.Resolve <TestDbContext>(); dbContext.Database.EnsureDeleted(); // after delete, scope and it's transaction are not much usable! } using (IDependencyResolver childDependencyResolver = _dependencyManager.CreateChildDependencyResolver()) { TestDbContext dbContext = childDependencyResolver.Resolve <TestDbContext>(); dbContext.Database.EnsureCreated(); dbContext.TestModels.Add(_testModel); dbContext.ParentEntities.AddRange(_parentEntities); TestCity city = new TestCity { Id = Guid.Parse("EF529174-C497-408B-BB4D-C31C205D46BB"), Name = "TestCity", Version = DateTimeOffset.UtcNow.Ticks }; TestCustomer customer = new TestCustomer { Id = Guid.Parse("28E1FF65-DA41-4FA3-8AEB-5196494B407D"), City = city, CityId = city.Id, Name = "TestCustomer", Version = DateTimeOffset.UtcNow.Ticks }; dbContext.TestCities.Add(city); dbContext.TestCustomers.Add(customer); dbContext.SaveChanges(); } }
public void ReturnsDeltaWithInvalidConversionStatus_WhenCannotConvertType() { var originalCustomer = new TestCustomer { FirstName = "originalFirstName", Age = 20 }; var newCustomer = new { FirstName = "originalFirstName", Age = "twenty-five" }; var newCustomerJObj = JObject.FromObject(newCustomer); var deltaGroup = DeltaObjectFromJObjectGenerator.GetDeltaObjects(originalCustomer, newCustomerJObj); Assert.NotNull(deltaGroup); Assert.Equal(GroupValueConversionStatus.AllFailed, deltaGroup.ValueConversionStatus); Assert.Single(deltaGroup.DeltaObjectsValueConversionFail); Assert.Empty(deltaGroup.DeltaObjects); Assert.Equal(ValueConversionStatus.Fail, deltaGroup.DeltaObjectsValueConversionFail[0].ValueConversionStatus); Assert.Equal(newCustomer.Age, deltaGroup.DeltaObjectsValueConversionFail[0].NewValue); }
public void DetectsDelta_WhenPropertyChangedToDefault() { var originalCustomer = new TestCustomer { DateOfBirth = new DateTime(1949, 3, 3), Age = 20 }; var newCustomer = new { DateOfBirth = default(DateTime), Age = default(int) }; var newCustomerJObj = JObject.FromObject(newCustomer); var deltaGroup = DeltaObjectFromJObjectGenerator.GetDeltaObjects(originalCustomer, newCustomerJObj); Assert.NotNull(deltaGroup); Assert.Equal(GroupValueConversionStatus.NoneFailed, deltaGroup.ValueConversionStatus); Assert.Equal(2, deltaGroup.DeltaObjects.Count); Assert.Empty(deltaGroup.DeltaObjectsValueConversionFail); Assert.Equal(ValueConversionStatus.Success, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.DateOfBirth)).ValueConversionStatus); Assert.Equal(newCustomer.DateOfBirth, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.DateOfBirth)).NewValue); Assert.Equal(ValueConversionStatus.Success, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.Age)).ValueConversionStatus); Assert.Equal(newCustomer.Age, deltaGroup.DeltaObjects.First(o => o.PropertyName == nameof(TestCustomer.Age)).NewValue); }
public void ReturnsSingleIntDeltaObject_WhenSingleIntDeltaExists() { var originalCustomer = new TestCustomer { FirstName = "originalFirstName", Age = 20 }; var newCustomer = new { FirstName = "originalFirstName", Age = 25 }; var newCustomerJObj = JObject.FromObject(newCustomer); var deltaGroup = DeltaObjectFromJObjectGenerator.GetDeltaObjects(originalCustomer, newCustomerJObj); Assert.NotNull(deltaGroup); Assert.Equal(GroupValueConversionStatus.NoneFailed, deltaGroup.ValueConversionStatus); Assert.Single(deltaGroup.DeltaObjects); Assert.Empty(deltaGroup.DeltaObjectsValueConversionFail); Assert.Equal(ValueConversionStatus.Success, deltaGroup.DeltaObjects[0].ValueConversionStatus); Assert.Equal(newCustomer.Age, deltaGroup.DeltaObjects[0].NewValue); }
public void Can_check_whether_customer_is_forum_moderator() { var customer = new TestCustomer(); customer.AddCustomerRoleMapping( new CustomerCustomerRoleMapping { CustomerRole = customerRoleRegistered } ); customer.AddCustomerRoleMapping( new CustomerCustomerRoleMapping { CustomerRole = customerRoleGuests } ); customer.IsForumModerator().ShouldBeFalse(); var customerRoleForumModerators = new CustomerRole { Active = true, Name = "ForumModerators", SystemName = QNetCustomerDefaults.ForumModeratorsRoleName }; customer.AddCustomerRoleMapping( new CustomerCustomerRoleMapping { CustomerRole = customerRoleForumModerators } ); customer.IsForumModerator().ShouldBeTrue(); }
public override global::System.Data.DataSet Clone() { TestCustomer cln = ((TestCustomer)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public void GetValue_WhenSingleStringMember_SingleValueIsReturned() { var property = StructurePropertyTestFactory.GetPropertyByPath<TestCustomer>("CustomerNo"); var customer = new TestCustomer { CustomerNo = "1234" }; var customerNos = (string)property.GetValue(customer); CollectionAssert.AreEqual("1234", customerNos); }
public void GetValue_WhenArrayOfInt_ReturnsAValueArray() { var property = StructurePropertyTestFactory.GetPropertyByPath<TestCustomer>("Points"); var container = new TestCustomer { Points = new[] { 5, 4, 3, 2, 1 } }; var values = (IEnumerable<int>)property.GetValue(container); CollectionAssert.AreEqual(new[] { 5, 4, 3, 2, 1 }, values); }
public void TestRegisterCustomer_NestedReusableBehaviours() { var customer1 = new TestCustomer(); var customer2 = new TestCustomer(); SoThat(MyValues.WeIncreaseCustomerBase) .As(new WebUser()) .GivenWe(x => RegisterAndConfirmCustomerRegistration(x, customer1.Named("customer 1"))) .AndWe(x => RegisterAndConfirmCustomerRegistration(x, customer2.Named("customer 2"))); }
public void TestRegisterCustomer_StandardBehaviour() { var customer = new TestCustomer(); SoThat(MyValues.WeIncreaseCustomerBase) .As(new WebUser()) .Given(customer.Named("initial customer").Has("completed").Registration) .When(customer.Has("confirmed").Registration) .Then(customer.Named("as returning customer").Login); }
public void ShouldLoginAsANewUserD() //'Should' gets renamed to 'I Want To' { var customer = new TestCustomer("*****@*****.**"); SoThat(MyBusinessValue.WeIncreaseTheCustomerBase) .As(new WebUser()) .GivenWe(x => FullyRegister(x, customer)) //delegate call to do a set of actions .When(customer.Has("confirmed").Registration) .Then(customer.Login); }
public void GetValues_WhenArrayOfInt_ReturnsAValueArray() { var propertyInfo = typeof(TestCustomer).GetProperty("Points"); var property = new Property(propertyInfo); var container = new TestCustomer { Points = new[] { 5, 4, 3, 2, 1 } }; var values = property.GetValues(container); CollectionAssert.AreEqual(new[] { 5, 4, 3, 2, 1 }, values); }
public void GetValues_WhenSingleStringMember_SingleValueIsReturned() { var propertyInfo = typeof(TestCustomer).GetProperty("CustomerNo"); var property = new Property(propertyInfo); var customer = new TestCustomer { CustomerNo = "1234" }; var customerNos = property.GetValues(customer); CollectionAssert.AreEqual(new[] {"1234"}, customerNos); }
public void GetValue_WhenArrayOfInt_ReturnsAValueArray() { var property = StructurePropertyTestFactory.GetPropertyByPath <TestCustomer>("Points"); var container = new TestCustomer { Points = new[] { 5, 4, 3, 2, 1 } }; var values = (IEnumerable <int>)property.GetValue(container); CollectionAssert.AreEqual(new[] { 5, 4, 3, 2, 1 }, values.ToArray()); }
public void IWantToRegisterANewUserA() { //Demonstrates basic usage var customer = new TestCustomer("*****@*****.**"); SoThat(MyBusinessValue.WeIncreaseTheCustomerBase) .As(new WebUser()) .Given(customer.Has("completed").Registration) .When(customer.Has("confirmed").Registration) .Then(customer.Login); }
public void GetValue_WhenSingleStringMember_SingleValueIsReturned() { var property = StructurePropertyTestFactory.GetPropertyByPath <TestCustomer>("CustomerNo"); var customer = new TestCustomer { CustomerNo = "1234" }; var customerNos = (string)property.GetValue(customer); Assert.AreEqual("1234", customerNos); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { TestCustomer ds = new TestCustomer(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public void add_element_to_hash() { var client = GetClient(); var cacheManager = new CacheRepository <TestCustomer, int>(client, m => m.Id); client.FlushDb(); var customer = new TestCustomer { Id = 1, Name = "John Smith" }; cacheManager.Set(customer); }
public void IWantToRegisterANewUserC() { //Demonstrates inline naming and renaming through test var user = new WebUser(); var newCustomer = new TestCustomer("*****@*****.**"); SoThat(MyBusinessValue.WeIncreaseTheCustomerBase) .As(user.Named("The user")) .Given(newCustomer.Named("customer for the first time").Has("completed").Registration) .When(newCustomer.Named("via email customer").Has("confirmed").Registration) .Then(newCustomer.Named("returning customer").Login); }
public void IWantToRegisterANewUserB() { //Demonstrates more descriptive naming of personas and entities var user = new WebUser().Named("a web user"); //naming by hand var newCustomer = new TestCustomer("*****@*****.**"); newCustomer.Named(() => newCustomer); //naming from variable name SoThat(MyBusinessValue.WeIncreaseTheCustomerBase) .As(user) .Given(newCustomer.Has("completed").Registration) .When(newCustomer.Has("confirmed").Registration) .Then(newCustomer.Login); }
public void IgnoresPrivateProperty_WhenPrivatePropertyHasDelta() { var originalCustomer = new TestCustomer(); originalCustomer.SetSecret("original secret"); var newCustomer = new TestCustomer(); newCustomer.SetSecret("new secret"); var deltaObjects = DeltaObjectFromObjectGenerator.GetDeltaObjects(originalCustomer, newCustomer); Assert.Empty(deltaObjects); }
public void Can_remove_address_assigned_as_billing_address() { var customer = new TestCustomer(); var address = new Address { Id = 1 }; customer.AddAddresses(address); customer.BillingAddress = address; customer.BillingAddress.ShouldBeTheSameAs(customer.Addresses.First()); customer.RemoveAddress(address); customer.Addresses.Count.ShouldEqual(0); customer.BillingAddress.ShouldBeNull(); }
public void ReturnsDelta_WhenDateTimeDeltaExists() { var originalCustomer = new TestCustomer { DateOfBirth = new DateTime(1979, 12, 8) }; var newCustomer = new TestCustomer { DateOfBirth = new DateTime(1979, 12, 7) }; var deltaObjects = DeltaObjectFromObjectGenerator.GetDeltaObjects(originalCustomer, newCustomer); Assert.Single(deltaObjects); }
public void AssociationConcat([DataSources] string context) { using (var db = GetDataContext(context)) using (db.CreateLocalTable <TestReceipt>()) using (db.CreateLocalTable <TestCustomer>()) { var query = db.GetTable <TestReceipt>() .Concat(db.GetTable <TestReceipt>().TableName(TestReceipt.ExternalReceiptsTableName)) .Select( i => new { i.ReceiptNo, a = TestCustomer.GetName(i.Customer.BillingGroup) }); Assert.Throws <LinqToDBException>(() => _ = query.ToArray(), "Associations with Concat/Union or other Set operations are not supported."); } }
private static void TestCustomers() { var client = new MongoDbCustomer(); var insert = false; if (insert) { var customer1 = TestCustomer.CreateUserFeature1(); client.InsertCustomerFeature1(customer1); var customer2 = TestCustomer.CreateUserFeature2(); client.InsertCustomerFeature2(customer2); } client.ReadCustomersFeature1(); client.ReadCustomersFeature2(); }
public void ReturnsZeroDeltaObjects_WhenPropertiesAreNull() { var originalCustomer = new TestCustomer { FirstName = default(string) }; var newCustomer = new TestCustomer { FirstName = default(string) }; var deltaObjects = DeltaObjectFromObjectGenerator.GetDeltaObjects(originalCustomer, newCustomer); Assert.NotNull(deltaObjects); Assert.Empty(deltaObjects); }
public virtual void OnAppStartup() { using (IDependencyResolver childDependencyResolver = _dependencyManager.CreateChildDependencyResolver()) { TestDbContext dbContext = null; if (Settings.Default.UseInMemoryProviderByDefault) { dbContext = childDependencyResolver.Resolve <TestDbContext>(); } else { DbContextOptionsBuilder dbContextOptionsBuilder = new DbContextOptionsBuilder(); SqlConnection dbConnection = new SqlConnection(DefaultAppEnvironmentProvider.Current.GetActiveAppEnvironment().GetConfig <string>("TestDbConnectionString")); dbContextOptionsBuilder.UseSqlServer(dbConnection); dbContext = new TestDbContext(dbContextOptionsBuilder.Options); } using (dbContext) { dbContext.Database.EnsureDeleted(); dbContext.Database.EnsureCreated(); dbContext.TestModels.Add(_testModel); dbContext.ParentEntities.AddRange(_parentEntities); TestCity city = new TestCity { Id = Guid.Parse("EF529174-C497-408B-BB4D-C31C205D46BB"), Name = "TestCity" }; TestCustomer customer = new TestCustomer { Id = Guid.Parse("28E1FF65-DA41-4FA3-8AEB-5196494B407D"), City = city, CityId = city.Id, Name = "TestCustomer" }; dbContext.TestCities.Add(city); dbContext.TestCustomers.Add(customer); dbContext.SaveChanges(); } } }
private void TestApplyItemsToCollection( TestCustomer customer, IEnumerable orders, MergeOption option, TestEntityTracker entityTracker, bool isContinuation) { var customerDescriptor = new EntityDescriptor(this.clientEdmModel) { Entity = customer }; var materializerEntry = MaterializerEntry.CreateEntryForLoadProperty(customerDescriptor, ODataFormat.Atom, true); materializerEntry.ActualType = this.clientEdmModel.GetClientTypeAnnotation(clientEdmModel.GetOrCreateEdmType(typeof(TestCustomer))); var adapter = new EntityTrackingAdapter( entityTracker, option, clientEdmModel, new DataServiceContext()); EntryValueMaterializationPolicy evmp = new EntryValueMaterializationPolicy( materializerContext, adapter, null, new Dictionary<IEnumerable, DataServiceQueryContinuation>()); evmp.ApplyItemsToCollection( materializerEntry, ordersProperty, orders, null, null, isContinuation); if (entityTracker.GetEntityDescriptorFunc != null) { adapter.MaterializationLog.ApplyToContext(); } }