コード例 #1
0
ファイル: AnimalUnitTests.cs プロジェクト: avivmag/Zoo-App
        public void UpdateAnimalStoryWrongEnclosureId()
        {
            var ans = new AnimalStory
            {
                id          = default(int),
                pictureUrl  = "pictureUrl1",
                enclosureId = -2,
            };

            context.UpdateAnimalStory(ans);
        }
コード例 #2
0
ファイル: AnimalUnitTests.cs プロジェクト: avivmag/Zoo-App
        public void UpdateAnimalStoryAddAnValidTest()
        {
            var animalStory = context.GetAllAnimalStories();

            Assert.AreEqual(2, animalStory.Count());

            var ans = new AnimalStory
            {
                id          = default(int),
                enclosureId = 2,
                pictureUrl  = "storyUrl1000"
            };

            context.UpdateAnimalStory(ans);

            animalStory = context.GetAllAnimalStories();
            Assert.AreEqual(3, animalStory.Count());
        }
コード例 #3
0
        public AnimalStory UpdateAnimalStory(AnimalStory animalStory)
        {
            try
            {
                using (var db = GetContext())
                {
                    if (!ValidateSessionId(db))
                    {
                        throw new AuthenticationException("Couldn't validate the session");
                    }

                    return(db.UpdateAnimalStory(animalStory));
                }
            }
            catch (Exception Exp)
            {
                var animalStoryInput = "Id: " + animalStory.id + ", enclosure Id: " + animalStory.enclosureId +
                                       ", picture Url: " + animalStory.pictureUrl;
                Logger.GetInstance(isTesting).WriteLine(Exp.Message, Exp.StackTrace, animalStoryInput);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }