public void MovePocoObject_Succeeds()
        {
            // Arrange
            var key1   = 100;
            var value1 = new Customer {
                Name = "James"
            };
            var key2   = 200;
            var value2 = new Customer {
                Name = "Mike"
            };
            var model = new CustomerDictionary();

            model.DictionaryOfStringToCustomer[key1] = value1;
            model.DictionaryOfStringToCustomer[key2] = value2;
            var patchDocument = new JsonPatchDocument();

            patchDocument.Move($"/DictionaryOfStringToCustomer/{key1}/Name", $"/DictionaryOfStringToCustomer/{key2}/Name");

            // Act
            patchDocument.ApplyTo(model);

            // Assert
            var actualValue2 = model.DictionaryOfStringToCustomer[key2];

            Assert.NotNull(actualValue2);
            Assert.Equal("James", actualValue2.Name);
        }
Esempio n. 2
0
        public void ReplacePocoObject_Succeeds()
        {
            // Arrange
            var key1   = 100;
            var value1 = new Customer()
            {
                Name = "Jamesss"
            };
            var key2   = 200;
            var value2 = new Customer()
            {
                Name = "Mike"
            };
            var model = new CustomerDictionary();

            model.DictionaryOfStringToCustomer[key1] = value1;
            model.DictionaryOfStringToCustomer[key2] = value2;
            var patchDocument = new JsonPatchDocument();

            patchDocument.Replace($"/DictionaryOfStringToCustomer/{key1}/Name", "James");

            // Act
            patchDocument.ApplyTo(model);

            // Assert
            Assert.Equal(2, model.DictionaryOfStringToCustomer.Count);
            var actualValue1 = model.DictionaryOfStringToCustomer[key1];

            Assert.NotNull(actualValue1);
            Assert.Equal("James", actualValue1.Name);
        }
Esempio n. 3
0
        private void LoadEdit(string id)
        {
            FollowID = id;
            o        = new Follow();//.Select(UsersID);
            o        = Follow.Select(id);

            CustomerID       = o.CustomerID;
            customerCbx.Text = CustomerDictionary.First(e => e.Value == o.CustomerID).Key;
            customerCbx_SelectedIndexChanged(null, null);

            UserID       = o.UserID;
            userCbx.Text = UserDictionary.First(e => e.Value == o.UserID).Key;
            userCbx_SelectedIndexChanged(null, null);

            ItemID          = o.ItemID;
            productCbx.Text = ProductDictionary.First(e => e.Value == o.ItemID).Key;
            productCbx_SelectedIndexChanged(null, null);

            typePhoneChk.Checked = (o.Type == "Phone") ? true : false;
            typeVisitChk.Checked = (o.Type == "Visit") ? true : false;
            diagnosisTxt.Text    = o.Diagnosis;
            hospitalTxt.Text     = o.Hospitalisation;
            sourceTxt.Text       = o.Source;
            foreach (ItemReview i in Model.ItemReview.List(o.Id))
            {
                ItemReview t = new ItemReview(id, i.FollowID, i.Title, i.Status, i.Details, DateTime.Now.ToString("dd-MM-yyyy H:m:s"), "false", Helper.CompanyID);
                GenericCollection.itemReviews.Add(t);
            }
            LoadItemReview();
            foreach (ItemStatus i in Model.ItemStatus.List(o.Id))
            {
                ItemStatus t = new ItemStatus(id, i.FollowID, i.Title, i.Status, i.Details, DateTime.Now.ToString("dd-MM-yyyy H:m:s"), "false", Helper.CompanyID);
                GenericCollection.itemStatus.Add(t);
            }
            LoadItemStatus();

            foreach (PatientStatus i in Model.PatientStatus.List(o.Id))
            {
                PatientStatus t = new PatientStatus(id, i.FollowID, i.Title, i.Status, i.Details, DateTime.Now.ToString("dd-MM-yyyy H:m:s"), "false", Helper.CompanyID);
                GenericCollection.patientStatus.Add(t);
            }
            LoadPatientStatus();
            lengthTxt.Text = o.Length;
            needTxt.Text   = o.Need;
            goalTxt.Text   = o.Goal;
            resultTxt.Text = o.Results;

            visitChk.Checked      = (o.FollowVisit == "Yes") ? true : false;
            phoneChk.Checked      = (o.FollowPhone == "Yes") ? true : false;
            nextTxt.Text          = o.Next;
            puTxt.Text            = o.Pu;
            authoriserTxt.Text    = o.Authoriser;
            employeeTxt.Text      = o.Signature;
            reasonTxt.Text        = o.Reason;
            authSignatureTxt.Text = o.Authoriser;
        }
Esempio n. 4
0
        private void AutoCompleteCustomer()
        {
            AutoCompleteStringCollection AutoItem = new AutoCompleteStringCollection();

            CustomerDictionary.Clear();
            foreach (Customer c in Customer.List())
            {
                AutoItem.Add((c.Name));

                if (!CustomerDictionary.ContainsKey(c.Name))
                {
                    CustomerDictionary.Add(c.Name, c.Id);
                    customerCbx.Items.Add(c.Name);
                }
            }
        }
        public void TestPocoObject_Succeeds()
        {
            // Arrange
            var key1   = 100;
            var value1 = new Customer {
                Name = "James"
            };
            var model = new CustomerDictionary();

            model.DictionaryOfStringToCustomer[key1] = value1;
            var patchDocument = new JsonPatchDocument();

            patchDocument.Test($"/DictionaryOfStringToCustomer/{key1}/Name", "James");

            // Act & Assert
            patchDocument.ApplyTo(model);
        }
        public void TestPocoObject_FailsWhenTestValueIsNotEqualToObjectValue()
        {
            // Arrange
            var key1   = 100;
            var value1 = new Customer {
                Name = "James"
            };
            var model = new CustomerDictionary();

            model.DictionaryOfStringToCustomer[key1] = value1;
            var patchDocument = new JsonPatchDocument();

            patchDocument.Test($"/DictionaryOfStringToCustomer/{key1}/Name", "Mike");

            // Act
            var exception = Assert.Throws <JsonPatchException>(() => { patchDocument.ApplyTo(model); });

            // Assert
            Assert.Equal("The current value 'James' at path 'Name' is not equal to the test value 'Mike'.", exception.Message);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Customer customer1 = new Customer
            {
                ID             = Guid.NewGuid(),
                Name           = "张三",
                Phone          = "8888-88888888",
                CompanyAddress = "江苏省 苏州市 星湖街 328号"
            };

            Customer customer2 = new Customer
            {
                ID             = Guid.NewGuid(),
                Name           = "李四",
                Phone          = "9999-99999999",
                CompanyAddress = "江苏省 苏州市 金鸡湖大道 328号"
            };

            CustomerDictionary customers = new CustomerDictionary();

            customers.Add(customer1.ID, customer1);
            customers.Add(customer2.ID, customer2);
            Serialize <CustomerDictionary>(customers, "customers.xml");
        }