public async Task ShooterRoastWithoutMention() { //ARRANGE //string for capturing command context message string cntxMsg = ""; //mock configuration Mock <IConfiguration> mockConfig = new Mock <IConfiguration>(); mockConfig.SetupGet(x => x[It.IsAny <string>()]).Returns("creatoruser"); //mock botstrings container Mock <IBotStringsContainer> mockBotStringsCntr = new Mock <IBotStringsContainer>(); mockBotStringsCntr.Setup(x => x.getContainer("shooter")) .Returns(_mockBotStrings.Object); //mock command context Mock <ICommandContext> mockCmdCntx = new Mock <ICommandContext>(); mockCmdCntx.Setup(x => x.Channel.SendMessageAsync(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <Embed>(), It.IsAny <RequestOptions>())) .Returns((string w, bool x, Embed y, RequestOptions z) => { cntxMsg = w; return(Task.FromResult <IUserMessage>(null)); }); //create the service ShooterService sutShooterService = new ShooterService(mockConfig.Object, mockBotStringsCntr.Object); //ACT await Task.Run(() => sutShooterService.roast(mockCmdCntx.Object, null)); //ASSERT Assert.That(cntxMsg, Is.EqualTo("@here Shooter quote")); }
public void Should_fail_when_one_shooter_has_more_than_minLoadout_WHEN_DECREASE() { // ARRANGE _originalShooter.Ammunitions = 100; // ACT ShooterService target = GetTarget(); Check.ThatCode(() => target.Decrease(ShooterIdentifier)) .Throws <Exception>() .WithMessage("Maximum loadout is 10."); }
public void Should_not_exceed_minimum_loadout_WHEN_decrease(int decraseTimes) { // ARRANGE _originalShooter.Ammunitions = 0; // ACT ShooterService target = GetTarget(); for (int i = 0; i < decraseTimes; i++) { target.Decrease(ShooterIdentifier); } // ASSERT Check.That(_originalShooter.Ammunitions).IsEqualTo(0); }
public void Should_not_exceed_maximum_loadout_WHEN_reload(int reloadTimes) { // ARRANGE _originalShooter.Ammunitions = 0; // ACT ShooterService target = GetTarget(); for (int i = 0; i < reloadTimes; i++) { target.Reload(ShooterIdentifier); } // ASSERT Check.That(_originalShooter.Ammunitions).IsEqualTo(10); }
public async Task ShooterPewPewUrl() { //ARRANGE //string for capturing command context message string cntxTtl = ""; string cntxImgUrl = ""; //mock configuration Mock <IConfiguration> mockConfig = new Mock <IConfiguration>(); mockConfig.SetupGet(x => x[It.IsAny <string>()]).Returns("creatoruser"); //mock botstrings container Mock <IBotStringsContainer> mockBotStringsCntr = new Mock <IBotStringsContainer>(); mockBotStringsCntr.Setup(x => x.getContainer("shooter")) .Returns(_mockBotStrings.Object); mockBotStringsCntr.Setup(x => x.getString("shooter", "pewpewtitle")) .Returns("PewPewTitle"); mockBotStringsCntr.Setup(x => x.getString("shooter", "pewpewurl")) .Returns("https://someurl/pewpewimg.png"); //mock command context Mock <ICommandContext> mockCmdCntx = new Mock <ICommandContext>(); mockCmdCntx.Setup(x => x.Channel.SendMessageAsync(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <Embed>(), It.IsAny <RequestOptions>())) .Returns((string w, bool x, Embed y, RequestOptions z) => { cntxTtl = y.Title; cntxImgUrl = y.Image.ToString(); return(Task.FromResult <IUserMessage>(null)); }); //create the service ShooterService sutShooterService = new ShooterService(mockConfig.Object, mockBotStringsCntr.Object); //ACT await Task.Run(() => sutShooterService.pewpew(mockCmdCntx.Object)); //ASSERT Assert.That(cntxTtl, Is.EqualTo("PewPewTitle")); Assert.That(cntxImgUrl, Is.EqualTo("https://someurl/pewpewimg.png")); }