コード例 #1
0
        public void Should_Update_Environment_In_Db(int id)
        {
            var fakeContext = new FakeContext("UpdateEnv");

            fakeContext.FillWith <Environment>();

            using (var context = new MainContext(fakeContext.FakeOptions))
            {
                var repository = new EnvironmentRepository(context);
                var currentEnv = repository.GetById(id);

                currentEnv.Name = "123abc";
                repository.Update(currentEnv);
                Assert.Equal("123abc", repository.GetById(id).Name);
            }
        }
コード例 #2
0
        public void Should_Return_Right_Environment_When_Find_By_Id_In_Db(int id)
        {
            var fakeContext = new FakeContext("EnvironmentById");

            fakeContext.FillWith <Environment>();

            using (var context = new MainContext(fakeContext.FakeOptions))
            {
                var expected   = fakeContext.GetFakeData <Environment>().Find(x => x.Id == id);
                var repository = new EnvironmentRepository(context);
                var actual     = repository.GetById(id);

                Assert.Equal(expected, actual, new EnvironmentIdComparer());
            }
        }
コード例 #3
0
        public void Should_Save_New_Environemnt_To_Db()
        {
            var fakeContext = new FakeContext("AddNewEnvironemnt");

            var fakeEnv = new Environment();

            fakeEnv.Name = "Desenvolvimento";
            fakeEnv.Id   = 4;

            using (var context = new MainContext(fakeContext.FakeOptions))
            {
                var repository = new EnvironmentRepository(context);
                repository.Create(fakeEnv);

                var createdEnv = repository.GetById(4);

                Assert.NotEqual(0, fakeEnv.Id);
                Assert.Equal("Desenvolvimento", createdEnv.Name);
                Assert.Equal(4, createdEnv.Id);
            }
        }