Esempio n. 1
0
        public void CreateReport_Limited()
        {
            var user = repository.Save(CreateEntry.User());

            for (int i = 0; i < 2; ++i)
            {
                var reporter = repository.Save(CreateEntry.User());
                permissionContext.SetLoggedUser(reporter);
                data.CreateReport(user.Id, UserReportType.Spamming, "mikumiku", "Too much negis!", reportCountLimit: 2, reportCountDisable: 3);
            }

            user.GroupId.Should().Be(UserGroupId.Limited);
            repository.List <UserReport>().Should().HaveCount(2);
        }
Esempio n. 2
0
        public SongControllerTests()
        {
            permissionContext.SetLoggedUser(repository.Save(CreateEntry.User()));
            var queries = new SongQueries(repository, permissionContext, new FakeEntryLinkFactory(),
                                          new FakePVParser(), new FakeUserMessageMailer(), new FakeLanguageDetector(), new FakeUserIconFactory(), new EnumTranslations(), new InMemoryImagePersister(),
                                          new FakeObjectCache(), new VdbConfigManager(), new EntrySubTypeNameFactory(), new FakeFollowedArtistNotifier());

            controller = new SongController(null, queries, null, null);
        }
Esempio n. 3
0
        public void SendMessage()
        {
            var sender   = CreateEntry.User(name: "sender");
            var receiver = CreateEntry.User(name: "receiver", email: "*****@*****.**");

            repository.Save(sender, receiver);
            permissionContext.SetLoggedUser(sender);
            var contract = new UserMessageContract {
                Sender = new UserForApiContract(sender), Receiver = new UserForApiContract(receiver), Subject = "Subject", Body = "Body"
            };

            data.SendMessage(contract, string.Empty, string.Empty);

            Assert.AreEqual(1, sender.Messages.Count, "Number of messages for sender");
            Assert.AreEqual(1, receiver.Messages.Count, "Number of messages for receiver");

            var messagesInRepo = repository.List <UserMessage>();

            Assert.AreEqual(2, messagesInRepo.Count, "Number of messages created");

            var sentMessage = messagesInRepo.FirstOrDefault(m => m.Inbox == UserInboxType.Sent);

            Assert.IsNotNull(sentMessage, "Sent message");
            Assert.AreEqual(sender.Messages[0], sentMessage, "Sent message is the same in user collection and repository");
            Assert.AreEqual("Subject", sentMessage.Subject, "sentMessage.Subject");
            Assert.AreEqual(sender, sentMessage.User, "Sent message user is the sender");
            Assert.AreEqual(receiver, sentMessage.Receiver, "sentMessage.Receiver");
            Assert.AreEqual(sender, sentMessage.Sender, "sentMessage.Sender");

            var receivedMessage = messagesInRepo.FirstOrDefault(m => m.Inbox == UserInboxType.Received);

            Assert.IsNotNull(receivedMessage, "Received message");
            Assert.AreEqual(receiver.Messages[0], receivedMessage, "Received message is the same in user collection and repository");
            Assert.AreEqual("Subject", receivedMessage.Subject, "receivedMessage.Subject");
            Assert.AreEqual(receiver, receivedMessage.User, "Received message user is the receiver");
            Assert.AreEqual(receiver, receivedMessage.Receiver, "receivedMessage.Receiver");
            Assert.AreEqual(sender, receivedMessage.Sender, "receivedMessage.Sender");

            Assert.IsNotNull(mailer.Subject, "mailer.Subject");
            Assert.AreEqual("*****@*****.**", mailer.ToEmail, "mailer.ToEmail");
        }