Exemplo n.º 1
0
        public async Task RemoveAuction_CallsRepositoryRemoveAuctionWithCorrectArguments()
        {
            //arrange
            var groupCode = 1;
            var auction   = GetAuctions("TestUser", groupCode).First(a => a.AuktionID == 3);
            var mocks     = CreateMocksForRemoveAuction(auction, "FirstName", "LastName", "TestUser", "TestUser", true);
            var auctions  = new Auctions(mocks.MockRepo.Object, mocks.MockUserManager.Object);
            //act
            await auctions.RemoveAuction(auction.AuktionID, groupCode, mocks.MockUser.Object);

            //assert
            mocks.MockRepo.Verify(r => r.RemoveAuction(auction.AuktionID, groupCode));
        }
Exemplo n.º 2
0
        public async Task RemoveAuction_ThrowsInvalidOperationException_WhenUserIsNotAllowedToRemoveAuction(string errorMessage, bool isAdmin, int auctionId, string createdBy)
        {
            //arrange
            var groupCode = 1;
            var auction   = GetAuctions(createdBy, groupCode).First(a => a.AuktionID == auctionId);
            var mocks     = CreateMocksForRemoveAuction(auction, "FirstName", "LastName", createdBy, createdBy, isAdmin);
            var auctions  = new Auctions(mocks.MockRepo.Object, mocks.MockUserManager.Object);
            //Act
            var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await auctions.RemoveAuction(auction.AuktionID, auction.Gruppkod, mocks.MockUser.Object);
            });

            // Assert
            Assert.Equal(errorMessage, exception.Message);
        }