public void Create(EulaModel viewModel, EducationSecurityPrincipal user) { if (viewModel == null) { throw new ArgumentNullException("viewModel"); } if (user == null) { throw new ArgumentNullException("user"); } if (!user.IsInRole(SecurityRoles.DataAdmin)) { throw new EntityAccessUnauthorizedException("user"); } EulaAgreement agreement = new EulaAgreement { CreateTime = DateTime.Now, CreatingUser = user.Identity.User }; viewModel.CopyTo(agreement); EulaAgreementRepository.Add(agreement); EulaAcceptance acceptance = new EulaAcceptance { EulaAgreement = agreement, CreatingUserId = user.Identity.User.Id, CreateTime = DateTime.Now }; if (user.Identity.User.EulaAcceptances == null) { user.Identity.User.EulaAcceptances = new List<EulaAcceptance>(); } user.Identity.User.EulaAcceptances.Add(acceptance); UserRepository.Update(user.Identity.User); RepositoryContainer.Save(); }
public void GivenAnEulaAgreement_WhenAdd_ThenAddToContext() { var expected = new EulaAgreement { Id = 1, EulaText = "blah" }; Target.Add(expected); MockDbSet.AssertWasCalled(m => m.Add(expected)); }
public void GivenValidModel_WhenCopyTo_ThenAllFieldsAreCopied() { var actual = new EulaAgreement(); Target.Id = TestData.Eulas[0].Id; Target.EulaText = TestData.Eulas[0].EulaText; Target.CopyTo(actual); Assert.AreEqual(Target.EulaText, actual.EulaText); }
private static bool AssertPropertiesMatch(EulaModel expectedState, EulaAgreement actualState) { Assert.IsNotNull(actualState); Assert.AreEqual(expectedState.EulaText, actualState.EulaText); return true; }
public void GivenAnEulaAgreement_WhenUpdate_ThenThrowException() { var expected = new EulaAgreement { Id = 1, EulaText = "blah" }; Target.ExpectException<NotSupportedException>(() => Target.Update(expected)); }
public void Update(EulaAgreement item) { throw new NotSupportedException("Update is not supported in this repository"); }
public void Add(EulaAgreement item) { Context.EulaAgreements.Add(item); }