예제 #1
0
        public void When_Update_Is_Called_After_Inserting_Valid_Data_It_Should_Update()
        {
            var telephoneDbOperation = new TelephoneNumberDbOperations();
            var telephone            = new TelephoneNumber()
            {
                UId = 2, PhoneNumber = "+91 9930774145", NumberType = "Work"
            };
            var pid = telephoneDbOperation.Create(telephone);

            telephone.UId         = 3;
            telephone.PhoneNumber = "+91 9820175604";
            telephone.NumberType  = "Home";

            telephone.PId = pid;

            telephoneDbOperation.Update(telephone);

            using (var con = new SqlConnection(TelephoneNumberDbOperations.ConnectionString))
            {
                var createdNumber = con.Query <TelephoneNumber>($"SELECT * FROM TelephoneNumbers WHERE PId = {pid}")
                                    .FirstOrDefault();


                Assert.AreEqual(createdNumber.PhoneNumber, telephone.PhoneNumber);
                Assert.AreEqual(createdNumber.NumberType, telephone.NumberType);
            }
        }
예제 #2
0
        public void When_Update_Is_Called_After_Setting_Exceeded_Length_Updated_Values_It_Should_Throw_A_SqlException(int uid, string number, string type,
                                                                                                                      int updatedUid, string updatedNumber, string updatedType)
        {
            var telephoneDbOperation = new TelephoneNumberDbOperations();
            var telephone            = new TelephoneNumber()
            {
                UId = uid, PhoneNumber = number, NumberType = type
            };
            var pid = telephoneDbOperation.Create(telephone);

            telephone.UId         = updatedUid;
            telephone.PhoneNumber = updatedNumber;
            telephone.NumberType  = updatedType;

            telephone.PId = pid;

            Assert.Throws <SqlException>(() => telephoneDbOperation.Update(telephone));
        }
        public void Update(TelephoneNumber telephone)
        {
            var numberServices = new TelephoneNumberDbOperations();

            numberServices.Update(telephone);
        }