Example #1
0
        public void HashCodeAndEqual()
        {
            var obj1 = MokProfile.GetSomeProfile();
            var obj2 = MokProfile.GetSomeProfile();

            // Хеш код и Equal
            Assert.IsTrue(obj1.GetHashCode() == obj2.GetHashCode());
            Assert.IsTrue(obj1.Equals(obj2));
        }
        public void SaveOrUpdate()
        {
            var conf = new Configuration();

            conf.WorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Test");

            IProfileRepository testRepository = new ProfileRepository(conf, new TestJob.Repository.EntityTextFormatter <Profile>());

            testRepository.SaveOrUpdate(MokProfile.GetSomeProfile());
        }
        public Profile FindByID( )
        {
            var conf = new Configuration();

            conf.WorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Test");

            IProfileRepository testRepository = new ProfileRepository(conf, new TestJob.Repository.EntityTextFormatter <Profile>());
            Profile            orign          = MokProfile.GetSomeProfile();
            Profile            profile        = testRepository.FindByID(orign.FIO + ".txt");

            Assert.Equals(orign, profile);
            return(orign);
        }
        public bool Delete( )
        {
            var conf = new Configuration();

            conf.WorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Test");

            var fio = MokProfile.GetSomeProfile().FIO + ".txt";
            IProfileRepository testRepository = new ProfileRepository(conf, new TestJob.Repository.EntityTextFormatter <Profile>());
            var res = testRepository.Delete(fio);;

            Assert.IsTrue(res);
            return(res);
        }
Example #5
0
        /// <summary>
        /// Проверка на вилидацию модели
        /// </summary>
        /// <param name="property"></param>
        /// <param name="s"></param>
        /// <returns></returns>
        private bool ValidatePropertyValue(string propertyName, object sValue)
        {
            var mokProfile = MokProfile.GetSomeProfile();

            var vResults = new List <ValidationResult>();
            var context  = new ValidationContext(mokProfile)
            {
                MemberName = propertyName
            };

            var result = Validator.TryValidateProperty(sValue, context, vResults);;

            return(result);
        }