Beispiel #1
0
        public void Should_Add_New_Challenge_When_Save()
        {
            var fakeContext = new FakeContext("SaveNewChallenge");

            var fakeChallenge = new Models.Challenge
            {
                Name      = "full name",
                Slug      = "pass",
                CreatedAt = DateTime.Today
            };

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var service = new ChallengeService(context);
                var actual  = service.Save(fakeChallenge);

                Assert.NotEqual(0, actual.Id);
            }
        }
        public void Should_Add_New_Challenge_When_Save()
        {
            var fakeContext   = new FakeContext("SaveNewChallenge");
            var fakeChallenge = new Models.Challenge();

            fakeChallenge.Name      = "name";
            fakeChallenge.Slug      = "slug";
            fakeChallenge.CreatedAt = DateTime.Today;

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var service = new ChallengeService(context);
                var actual  = service.Save(fakeChallenge);

                Assert.NotEqual(0, actual.Id);
                Assert.Equal(fakeChallenge.Name, actual.Name);
                Assert.Equal(fakeChallenge.Slug, actual.Slug);
                Assert.Equal(fakeChallenge.CreatedAt, actual.CreatedAt);
            }
        }
        public void SaveTeste_When_Update_Id_Not_Exist()
        {
            var fakeContext = new FakeContext("UpdateChallengeNotExist");

            fakeContext.FillWith <Models.Challenge>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var expected = new Models.Challenge();
                expected.Id        = 999;
                expected.Name      = "name";
                expected.Slug      = "slug";
                expected.CreatedAt = DateTime.Today;

                var service = new ChallengeService(context);
                var actual  = service.Save(expected);

                Assert.NotEqual(0, actual.Id);
                Assert.Equal(expected.Name, actual.Name);
                Assert.Equal(expected.Slug, actual.Slug);
                Assert.Equal(expected.CreatedAt, actual.CreatedAt);
            }
        }