private BasicProfileItem GetRandomProfile() { string mockupPath = @"..\..\..\MOCK_DATA.json"; string customers_mockupjson = System.IO.File.ReadAllText(mockupPath); ICollection <MockCustomer> mock_customers = JsonConvert.DeserializeObject <ICollection <MockCustomer> >(customers_mockupjson); List <MockCustomer> _mockupCustomer = new List <MockCustomer>(); foreach (var item in mock_customers) { var customer = new MockCustomer() { first_name = item.first_name, last_name = item.last_name, City = item.City, State = item.State, Street = item.Street, zip = "10005-1234", FedIncome = item.FedIncome, StateIncome = item.StateIncome, Dateofbirth = item.Dateofbirth }; _mockupCustomer.Add(customer); } var _mockCustomer = _mockupCustomer[new Random().Next(0, 99)]; return(new BasicProfileItem() { Name = $"{_mockCustomer.first_name} {_mockCustomer.last_name}", Address = new Address() { City = _mockCustomer.City, Street = _mockCustomer.Street, State = _mockCustomer.State, Zip = _mockCustomer.zip }, ApplicationType = ApplicationType.Indivisual, CitizenShip = true, DateOfBirth = _mockCustomer.Dateofbirth, //Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(_mockCustomer.Dateofbirth.ToUniversalTime()), FedIncome = _mockCustomer.FedIncome, StateIncome = _mockCustomer.StateIncome }); }
public void AccessEntityRef_Setter() { // Add cross-domain context reference this.CustomerDomainService.AddReference(typeof(City), this.CityDomainContext); // Load both data sources this.EnqueueLoadReferencedTypes(); this.EnqueueLoadCustomers(); this.EnqueueCallback( () => { MockCustomer cust = this.CustomerDomainService.MockCustomers.First(); Assert.IsTrue(cust.City != null); int count = 0; cust.PropertyChanged += (s, e) => { if (e.PropertyName == "City") { count++; } }; // set to a new valid city and validate City newCity = this.CityDomainContext.Cities.First(p => p.Name != cust.City.Name); cust.City = newCity; Assert.AreEqual(newCity.Name, cust.CityName); Assert.AreEqual(newCity.StateName, cust.StateName); Assert.AreEqual(1, count); // set to null and validate results count = 0; cust.City = null; Assert.AreEqual(null, cust.CityName); Assert.AreEqual(null, cust.StateName); Assert.AreEqual(1, count); }); this.EnqueueTestComplete(); }
public void PropertyChangedNotifications() { MockCustomer customer = null; int collectionChanged = 0; int propertyChanged = 0; // Add cross-domain context reference this.CustomerDomainService.AddReference(typeof(City), this.CityDomainContext); // Load data this.EnqueueLoadCustomers(); this.EnqueueCallback( () => { customer = this.CustomerDomainService.MockCustomers.First(); // Should be null/empty before we load reference data Assert.IsNull(customer.City); Assert.AreEqual <int>(0, customer.PreviousResidences.Count); // Sign up for collection changed events, increment counter each time. ((INotifyCollectionChanged)customer.PreviousResidences).CollectionChanged += (s, a) => collectionChanged += (a.Action == NotifyCollectionChangedAction.Add ? 1 : 0); // Sign up for property changed events, increment counter each time. customer.PropertyChanged += (s, a) => propertyChanged += (a.PropertyName == "City" ? 1 : 0); }); // Load referenced data (after event handlers attached) this.EnqueueLoadReferencedTypes(); // Verify we received the proper number of notifications this.EnqueueConditional(() => 1 == propertyChanged && customer.PreviousResidences.Count == collectionChanged); this.EnqueueTestComplete(); }