public void Test_OrgOwner_ItemExists_Success() { var user = DefaultTestData.ServiceStackUser1; var organisation = new Organisation("organisation"); var item = new Item("Title", "Creator", "Edition"); SaveEntities(user, organisation, item); CommitTransactionAndOpenNew(); var request = new AddOrganisationItemRequest() { OwnerId = organisation.Id, Creator = item.Creator, Edition = item.Edition, Title = item.Title }; var expectedResponse = new BaseResponse(); var expectedOwnership = new Ownership <Organisation>(item, organisation); var sut = new AddItemRequestHandler <Organisation>(() => Session); BaseResponse actualResponse = sut.HandleRequest(request, user.Id); actualResponse.ShouldEqual(expectedResponse); CommitTransactionAndOpenNew(); Ownership <Organisation> ownershipInDb = Session .QueryOver <Ownership>() .JoinQueryOver <Item>(x => x.Item) .Where(x => x.Id == item.Id) .SingleOrDefault <Ownership <Organisation> >() ; ownershipInDb.ShouldEqual(expectedOwnership); }
public void Test_OrgOwner_ItemExists_Success() { var user = DefaultTestData.ServiceStackUser1; var organisation = new Organisation("organisation"); var item = new Item("Title", "Creator", "Edition"); SaveEntities(user, organisation, item); CommitTransactionAndOpenNew(); var request = new AddOrganisationItemRequest() { OwnerId = organisation.Id, Creator = item.Creator, Edition = item.Edition, Title = item.Title }; var expectedResponse = new BaseResponse(); var expectedOwnership = new Ownership<Organisation>(item, organisation); var sut = new AddItemRequestHandler<Organisation>(() => Session); BaseResponse actualResponse = sut.HandleRequest(request, user.Id); actualResponse.ShouldEqual(expectedResponse); CommitTransactionAndOpenNew(); Ownership<Organisation> ownershipInDb = Session .QueryOver<Ownership>() .JoinQueryOver<Item>(x => x.Item) .Where(x => x.Id == item.Id) .SingleOrDefault<Ownership<Organisation>>() ; ownershipInDb.ShouldEqual(expectedOwnership); }