public void ADD_GivenAWineModel_WhenTheWineModelIsCreated_AddItToTheDatabase()
        {
            //Arrange
            WineModel newWineModel = new WineModel
            {
                Colour = Recipes.Business.Models.Enums.WineColourModel.Rose,
                CountryOfOrigin = "Spain",
                CreateDateTime = DateTime.Now,
                CreatedByAuthor = "Gabriel Renom",
                MainGrape = "Tempranillo",
                ModifiedBy = "Gabriel Renom",
                ModifiedDateTime = DateTime.Now,
                Name = "Tomas Buendia",
                Region = "Central Castile",
                TastingNotes = "Spanish red bursting with fruit - think ripe berries and liquorice",
                Vintage = 2009
            };

            //Act
            var result = manager.Add(newWineModel);
            repository.Commit();

            //Assert
            Assert.IsInstanceOfType(result, typeof(WineModel));
        }
 public async Task<HttpResponseMessage> Update(WineModel wine)
 {
     WineModel model = new WineModel();
     try
     {
         model = await _wineService.UpdateAsync(wine);
     }
     catch (HttpRequestException ex)
     {
         Trace.TraceError(ex.Message);
         return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
     }
     catch (WebException we)
     {
         Trace.TraceError(we.Message);
         return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, we.Message);
     }
     catch (SecurityException se)
     {
         Trace.TraceError(se.Message);
         return Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Not Authorised to this server!!");
     }
     catch (Exception ex)
     {
         Trace.TraceError(ex.Message);
         return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
     }
     return Request.CreateResponse(HttpStatusCode.OK, model);
 }
        public async Task WhenWeDoAPost_WeAddARecipe_AndWeWantToBeSureThatTheWineIsReturned()
        {
            //Arrange
            WineModel newWineModel = new WineModel
            {
                Colour = Recipes.Business.Models.Enums.WineColourModel.Red,
                CountryOfOrigin = "Chile",
                CreateDateTime = DateTime.Now,
                CreatedByAuthor = "Margaret Harding",
                MainGrape = "Sauvignon Blanc",
                ModifiedBy = "Terrry McPherson",
                ModifiedDateTime = DateTime.Now,
                Name = "Tadpole North",
                Region = "South",
                TastingNotes = "Dry with fruity overtones",
                Vintage = 2015
            };


            //Act
            WineModel wine = new WineModel();
            var result = await winesController.Add(newWineModel);
            result.TryGetContentValue(out wine);

            //Assert
            Assert.IsNotNull(wine);
            Assert.AreEqual(wine.GetType(), typeof(WineModel));
            Assert.IsTrue(wine.Id > 1);
        }
 public async Task<WineModel> UpdateAsync(WineModel wine)
 {
     return await _wineManager.UpdateAsync(wine);
 }
 public async Task<WineModel> AddAsync(WineModel wine)
 {
     return await _wineManager.AddAsync(wine);
 }
        public void UPDATE_GivenAnExitingWine_UpadateTheVintage()
        {
            //Arrange
            WineModel existingWineModel = new WineModel
            {
                Id = 3,
                Colour = Recipes.Business.Models.Enums.WineColourModel.Rose,
                CountryOfOrigin = "Spain",
                CreateDateTime = DateTime.Now,
                CreatedByAuthor = "Gabriel Renom",
                MainGrape = "Tempranillo",
                ModifiedBy = "Gabriel Renom",
                ModifiedDateTime = DateTime.Now,
                Name = "Tomas Buendia",
                Region = "Central Castile",
                TastingNotes = "Spanish red bursting with fruit - think ripe berries and liquorice",
                Vintage = 2011
            };

            //Act
            var result = manager.Update(existingWineModel);
            repository.Commit();

            //Assert
            Assert.IsInstanceOfType(result, typeof(WineModel));
            Assert.IsNotNull(result);
        }
        public async Task WhenWeDoAPut_TheWineGetsUpdated()
        {
            //Arrange
            WineModel existingWineModel = new WineModel
            {
                Id = 6,
                Colour = Recipes.Business.Models.Enums.WineColourModel.Red,
                CountryOfOrigin = "Chile",
                CreateDateTime = DateTime.Now,
                CreatedByAuthor = "TEST TO UPDATE WINE MODEL",
                MainGrape = "Sauvignon Blanc",
                ModifiedBy = "Terrry McPherson",
                ModifiedDateTime = DateTime.Now,
                Name = "Tadpole North",
                Region = "South",
                TastingNotes = "Dry with fruity overtones",
                Vintage = 2015
            };

            //Act
            WineModel changedWineModel = new WineModel();
            var result = await winesController.Update(existingWineModel);
            result.TryGetContentValue(out changedWineModel);

            //Arrange
            Assert.IsTrue(changedWineModel.CreatedByAuthor == existingWineModel.CreatedByAuthor);
            Assert.IsNotNull(changedWineModel);
        }