コード例 #1
0
        public void property_remains_the_same_if_no_substitution_was_added()
        {
            //arrange
            UserModel model = new UserModel() { Id = 100, Name = "John" };
            var subsItem = Configurator.SubstitutesFor(model.GetType());

            //act
            EntitySubstitutor.EntityToReal<UserModel>(model);

            //assert
            Assert.AreEqual(100, model.Id, "Id should be the same as we didn`t configure the substitutable.");
        }
コード例 #2
0
        public void single_id_property_is_substituted()
        {
            //arrange
            Configurator.Substitute<UserModel, int>(x => x.Id);

            UserModel model = new UserModel(){Id=100, Name="John"};
            var subsItem = Configurator.SubstitutesFor(model.GetType());

            //act
            EntitySubstitutor.EntityToReal<UserModel>(model);

            //assert
            Assert.AreEqual(10, model.Id, "Id should be substituted to real");
        }
コード例 #3
0
        public void property_set_to_value_provided()
        {
            //arrange
            UserModel model = new UserModel() { Id = 111, Name = "John" };
            Configurator.Substitute<UserModel, int>(x => x.Id);

            Substitutable subs = Configurator.SubstitutesFor(typeof(UserModel)).First();

            //act
            ReflectionHelper.SetValue<UserModel>(model, subs, 10);

            //assert
            Assert.AreEqual(10, model.Id);
        }
コード例 #4
0
        public void property_value_received_by_substitutable()
        {
            //arrange
            UserModel model = new UserModel() { Id = 111, Name = "John" };
            Configurator.Substitute<UserModel, int>(x => x.Id);

            Substitutable subs = Configurator.SubstitutesFor(typeof(UserModel)).First();

            //act
            int res = ReflectionHelper.GetValue<UserModel>(model, subs);

            //assert
            Assert.AreEqual(111, res);
            //Assert.AreNotEqual(1, model.Id);
        }