public void ShouldReturnSuccessForAdd() { RestaurantModel rm = new RestaurantModel() { RestaurantName = "testName", RestaurantAddress = "testAddress", }; bool operationSucceeded = false; string dataAccessStatusJsonStr = string.Empty; string formatedJsonString = string.Empty; try { _restaurantServices.Add(rm); operationSucceeded = true; } catch (DataAccessException dataAccessException) { operationSucceeded = dataAccessException.DataAccessStatusInfo.OperationSucceded; dataAccessStatusJsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(dataAccessException.DataAccessStatusInfo); formatedJsonString = JToken.Parse(dataAccessStatusJsonStr).ToString(); } try { Assert.True(operationSucceeded); _testOutputHelper.WriteLine("The restaurant was successfully added"); } finally { _testOutputHelper.WriteLine(formatedJsonString); } }
private void addRestaurantBtn_Click(object sender, EventArgs e) { string restaurantName = restaurantNameTB.Text; string restaurantAddress = restaurantAddressTB.Text; string _connectionString = "Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\OO_PocketGourmet_REAL-UnitTest\MVPDB.sqlite;"; RestaurantServices restaurantServices = new RestaurantServices(new RestaurantRepository(_connectionString), new ModelDataAnnotationCheck()); RestaurantModel restaurant = new RestaurantModel() { RestaurantName = restaurantName, RestaurantAddress = restaurantAddress, }; restaurantServices.Add(restaurant); MessageBox.Show("Restaurant Added"); }