tests creation

This commit is contained in:
Nicolas Constant 2021-02-15 18:27:24 -05:00
parent 0871243a18
commit aea0244b2a
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
6 changed files with 149 additions and 0 deletions

View file

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BirdsiteLive.ActivityPub;
using BirdsiteLive.Common.Settings;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Domain;
using BirdsiteLive.Moderation.Actions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace BirdsiteLive.Moderation.Tests.Actions
{
[TestClass]
public class RejectAllFollowingsActionTests
{
[TestMethod]
public async Task ProcessAsync()
{
#region Stubs
var follower = new Follower
{
Followings = new List<int>
{
24
},
Host = "host"
};
var settings = new InstanceSettings
{
Domain = "domain"
};
#endregion
#region Mocks
var twitterUserDalMock = new Mock<ITwitterUserDal>();
twitterUserDalMock
.Setup(x => x.GetTwitterUserAsync(
It.Is<int>(y => y == 24)))
.ReturnsAsync(new SyncTwitterUser
{
Id = 24,
Acct = "acct"
});
var userServiceMock = new Mock<IUserService>();
userServiceMock
.Setup(x => x.SendRejectFollowAsync(
It.Is<ActivityFollow>(y => y.type == "Follow"),
It.IsNotNull<string>()
))
.ReturnsAsync(true);
#endregion
var action = new RejectAllFollowingsAction(twitterUserDalMock.Object, userServiceMock.Object, settings);
await action.ProcessAsync(follower);
#region Validations
twitterUserDalMock.VerifyAll();
userServiceMock.VerifyAll();
#endregion
}
[TestMethod]
public async Task ProcessAsync_Exception()
{
#region Stubs
var follower = new Follower
{
Followings = new List<int>
{
24
},
Host = "host"
};
var settings = new InstanceSettings
{
Domain = "domain"
};
#endregion
#region Mocks
var twitterUserDalMock = new Mock<ITwitterUserDal>();
twitterUserDalMock
.Setup(x => x.GetTwitterUserAsync(
It.Is<int>(y => y == 24)))
.ReturnsAsync(new SyncTwitterUser
{
Id = 24,
Acct = "acct"
});
var userServiceMock = new Mock<IUserService>();
userServiceMock
.Setup(x => x.SendRejectFollowAsync(
It.Is<ActivityFollow>(y => y.type == "Follow"),
It.IsNotNull<string>()
))
.Throws(new Exception());
#endregion
var action = new RejectAllFollowingsAction(twitterUserDalMock.Object, userServiceMock.Object, settings);
await action.ProcessAsync(follower);
#region Validations
twitterUserDalMock.VerifyAll();
userServiceMock.VerifyAll();
#endregion
}
}
}

View file

@ -0,0 +1,7 @@
namespace BirdsiteLive.Moderation.Tests.Actions
{
public class RejectFollowingActionTests
{
}
}

View file

@ -0,0 +1,7 @@
namespace BirdsiteLive.Moderation.Tests.Actions
{
public class RemoveFollowerActionTests
{
}
}

View file

@ -0,0 +1,7 @@
namespace BirdsiteLive.Moderation.Tests.Actions
{
public class RemoveTwitterAccountActionTests
{
}
}

View file

@ -0,0 +1,7 @@
namespace BirdsiteLive.Moderation.Tests.Processors
{
public class FollowerModerationProcessorTests
{
}
}

View file

@ -0,0 +1,7 @@
namespace BirdsiteLive.Moderation.Tests.Processors
{
public class TwitterAccountModerationProcessorTests
{
}
}