public void RegisterVoteForSameEntryThrowsInvalidOperationException() { var settings = new CoreSettings { MaxVoteCount = 2 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = SetupVotedEntry(); accessControl.RegisterVote(token, entry); entry.Vote(); Assert.Throws<InvalidOperationException>(() => accessControl.RegisterVote(token, entry)); }
public async Task SmokeTest() { AccessControl accessControl = SetupVotableAccessControl(2); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.RegisterVote(token, SetupVotedEntry()); Assert.Equal(1, await accessControl.ObserveRemainingVotes(token).FirstAsync()); }
public void ThrowsInvalidOperationExceptionIfGuestSystemIsDisabled() { var settings = new CoreSettings { EnableGuestSystem = false }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws <InvalidOperationException>(() => accessControl.RegisterVote(token, SetupVotedEntry())); }
public void WithoutVotesLeftThrowsInvalidOperationException() { var settings = new CoreSettings { EnableGuestSystem = true, MaxVoteCount = 0 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws <InvalidOperationException>(() => accessControl.RegisterVote(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }
public void SmokeTest() { var settings = new CoreSettings { EnableGuestSystem = true }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = SetupVotedEntry(); accessControl.RegisterVote(token, entry); Assert.True(accessControl.IsVoteRegistered(token, entry)); Assert.False(accessControl.IsVoteRegistered(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }
public void RegisteredVoteUnregistersAutomaticallyWhenEntryvoteCountIsReset() { var settings = new CoreSettings { MaxVoteCount = 2 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = new PlaylistEntry(0, Helpers.SetupSongMock()); entry.Vote(); var votes = accessControl.ObserveRemainingVotes(token).CreateCollection(); accessControl.RegisterVote(token, entry); entry.ResetVotes(); Assert.Equal(new int?[] { 2, 1, 2 }, votes); }
public void WithoutVotesLeftThrowsInvalidOperationException() { var settings = new CoreSettings { EnableVotingSystem = true, MaxVoteCount = 0 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws<InvalidOperationException>(() => accessControl.RegisterVote(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }
public void ThrowsInvalidOperationExceptionIfVotingIsDisabled() { var settings = new CoreSettings { EnableVotingSystem = false }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws<InvalidOperationException>(() => accessControl.RegisterVote(token, SetupVotedEntry())); }
public async Task SmokeTest() { var settings = new CoreSettings { EnableVotingSystem = true, MaxVoteCount = 2 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.RegisterVote(token, SetupVotedEntry()); Assert.Equal(settings.MaxVoteCount - 1, await accessControl.ObserveRemainingVotes(token).FirstAsync()); }
public void SmokeTest() { var settings = new CoreSettings(); var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var votes = accessControl.ObserveRemainingVotes(token).CreateCollection(); accessControl.RegisterVote(token, SetupVotedEntry()); accessControl.RegisterVote(token, SetupVotedEntry()); Assert.Equal(new int?[] { 2, 1, 0 }, votes); }
public void SmokeTest() { var settings = new CoreSettings { EnableVotingSystem = true }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = SetupVotedEntry(); accessControl.RegisterVote(token, entry); Assert.True(accessControl.IsVoteRegistered(token, entry)); Assert.False(accessControl.IsVoteRegistered(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }