public void ApiGetMemberships() { var acc = Mock.Of <IMembershipService>(a => a.GetMemberships() == _activeMemberships); var uow = Mock.Of <IUnitOfWork>(u => u.MembershipService == acc); var controller = new MembershipsController(uow); var memberships = controller.GetMemberships(); Assert.IsTrue(memberships.EqualValues(_activeMemberships)); }
public void ApiGetMembershipsByTeam() { long teamId = 14; var membership = _memberMembership; var userMemberships = new Membership[] { membership }; var acc = Mock.Of <IMembershipService>(a => a.GetMemberships(teamId) == userMemberships); var uow = Mock.Of <IUnitOfWork>(u => u.MembershipService == acc); var controller = new MembershipsController(uow); var memberships = controller.GetMemberships(teamId); Assert.IsTrue(memberships.EqualValues(userMemberships)); }
public void ApiGetMembership() { long id = 1; var membership = _adminMembership; var acc = Mock.Of <IMembershipService>(a => a.GetMembership(id) == membership); var uow = Mock.Of <IUnitOfWork>(u => u.MembershipService == acc); var controller = new MembershipsController(uow); var response = controller.GetMembership(id); var result = response as OkNegotiatedContentResult <MembershipDto>; var resultMembership = result.Content; Assert.IsTrue(resultMembership.EqualValues(membership)); }
public void ApiGetMembershipByTeamUser() { long teamId = 14; string userId = "abc"; var membership = _memberMembership; var acc = Mock.Of <IMembershipService>(a => a.GetMembership(teamId, userId) == membership); var uow = Mock.Of <IUnitOfWork>(u => u.MembershipService == acc); var controller = new MembershipsController(uow); var response = controller.GetMembership(userId, teamId); var result = response as OkNegotiatedContentResult <MembershipDto>; var resultMembership = result.Content; Assert.IsTrue(resultMembership.EqualValues(membership)); }
public void ApiPostMembership() { var membership = _memberMembership; var mock = new Mock <IMembershipService>(); mock.Setup(acc => acc.CreateMembership(membership)) .Returns(membership); var uowMock = new Mock <IUnitOfWork>(); uowMock.Setup(u => u.MembershipService) .Returns(mock.Object); var con = new MembershipsController(uowMock.Object); con.PostMembership(membership); mock.Verify(acc => acc.CreateMembership(membership)); uowMock.Verify(u => u.Save()); }
public void PutMembershipDeletesTeamWhenLastMembershipMadeNonActive() { long id = 3; var membership = _bannedMembership; var memMock = new Mock <IMembershipService>(); memMock.Setup(acc => acc.UpdateMembership(membership)) .Returns(membership); var remainingMemberships = new Membership[] { }; var uowMock = new Mock <IUnitOfWork>(); uowMock.Setup(u => u.MembershipService) .Returns(memMock.Object); var con = new MembershipsController(uowMock.Object); con.PutMembership(id, membership); memMock.Verify(acc => acc.UpdateMembership(membership)); uowMock.Verify(u => u.Save()); }