public void AddVoteOnRequest_WithAsignee_ShouldThrowException() { //Arrange var cakeRequest = new CakeRequest(_fakeCreator, _fakeAssignee, "New shield.."); // Act and assert Assert.Throws <VoterIsAsigneeException>(() => cakeRequest.AddVote(_fakeAssignee)); }
public void AddRequest_ShouldReturnRequest() { // Arrange and Act var cakeRequest = new CakeRequest(_fakeCreator, _fakeAssignee, "New shield.."); // Assert Assert.Equal(typeof(CakeRequest), cakeRequest.GetType()); }
public async Task <CakeRequest> AddAsync(CakeRequest entity) { _log.LogInformation($"Adding cake request from user id {entity.CreatedById} to user id {entity.AssignedToId}"); _cakelistContext.Requests.Add(entity); await _cakelistContext.SaveChangesAsync(); _log.LogInformation($"Added cake request with id: {entity.Id}"); return(entity); }
public void AddMultipleVoteOnRequest_WithSameUser_ShouldThrowException() { //Arrange var cakeRequest = new CakeRequest(_fakeCreator, _fakeAssignee, "New shield.."); // Act - First vote should be fine cakeRequest.AddVote(_fakeVoter); // Act and assert Assert.Throws <VoterHasVotedException>(() => cakeRequest.AddVote(_fakeVoter)); }
public void AddVote_ShouldReturnSameVoter() { //Arrange var cakeRequest = new CakeRequest(_fakeCreator, _fakeAssignee, "New shield.."); // Act cakeRequest.AddVote(_fakeVoter); var voterId = cakeRequest.Votes.First().CreatedById; // Assert Assert.Equal(_fakeVoter.Id, voterId); }
public async Task UpdateAsync(CakeRequest entity) { _log.LogInformation($"Updating cake request with id: {entity.Id}"); //var request = await _cakelistContext.Requests.SingleOrDefaultAsync(r => r.Id == entity.Id); //TODO: Refactor to update only selected fields //request = entity; _cakelistContext.Requests.Update(entity); await _cakelistContext.SaveChangesAsync(); _log.LogInformation("Cake request updated"); }
public static void Initialize(CakelistContext cakelistContext) { cakelistContext.Database.EnsureCreated(); // Seed user data if (cakelistContext.Users.Any()) { return; // Database has already Users } var users = new User[] { new User { FirstName = "Tony", LastName = "Stark", Email = "*****@*****.**" }, new User { FirstName = "Steven", LastName = "Rogers", Email = "*****@*****.**" }, new User { FirstName = "Bruce", LastName = "Banner", Email = "*****@*****.**" } }; foreach (User user in users) { cakelistContext.Users.Add(user); } cakelistContext.SaveChanges(); // Seed request data if (cakelistContext.Requests.Any()) { return; } ; var request = new CakeRequest { CreatedById = 1, AssignedToId = 2, Reason = "New shield" }; request.AddVote(users[2]); cakelistContext.Requests.Add(request); cakelistContext.SaveChanges(); }
public async Task <CakeRequest> AddCakeRequestAsync(User createdBy, User assignedTo, string reason) { var request = new CakeRequest(createdBy, assignedTo, reason); await _cakeRequestRepository.AddAsync(request); var subject = "You have been assigned a cake request"; var message = $"Hello {assignedTo.FullName()}" + $"You have been assigned a cake request by {createdBy.FullName()} on the Cakelist with the reason: {reason}." + $"Cake request id: {request.Id}" + $"Number of votes: {request.Votes.Count}" + $"" + $"Best regards" + $"Your friendly Cakelist"; await _userNotificationService.NotifyUserAsync(assignedTo, subject, message); return(request); }
private void SetModelToUI(CakeRequest order) { textBox1.Text = order.FullName; dateTimePicker1.Value = order.OrderDate; dateTimePicker2.Value = order.Deadline; label10.Text = order.Price; int countCakes = 0; foreach (var Cake in order.TypeCakes) { countCakes++; } for (int i = 0; i < countCakes; i++) { DecorationsList.Add(order.TypeCakes[i].DecorationType); dataGridView1.Rows.Add(order.TypeCakes[i].CakeShape, order.TypeCakes[i].ShellType, order.TypeCakes[i].NumberTiers, order.TypeCakes[i].FillingType, GetItemsFromListFile(i)); } this.ShowDialog(); }