Beispiel #1
0
            public void ResponseContainsNewUUIDAndManageId()
            {
                Guid pollId = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");

                var existingPoll = new Poll()
                {
                    CreatorIdentity = UserId1, UUID = pollId
                };

                var dbPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    existingPoll
                };

                IContextFactory     mockContextFactory = CreateContextFactory(dbPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = pollId
                };


                CopyPollResponseModel response = controller.Copy(request);

                Poll copiedPoll = dbPolls.ToList()[1];

                Assert.AreEqual(copiedPoll.UUID, response.NewPollId);
                Assert.AreEqual(copiedPoll.ManageId, response.NewManageId);
            }
Beispiel #2
0
            public void CopiedPollHasSameValuesAsOriginal()
            {
                Guid           pollId        = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");
                const string   creator       = "Someone";
                const PollType pollType      = PollType.UpDown;
                const int      maxPoints     = 9;
                const int      maxPerVote    = 2;
                const bool     inviteOnly    = true;
                const bool     namedVoting   = true;
                DateTime?      expiryDateUtc = new DateTime(2015, 6, 2, 14, 2, 56, DateTimeKind.Utc);
                const bool     optionAdding  = true;

                var existingPoll = new Poll()
                {
                    UUID            = pollId,
                    Creator         = creator,
                    CreatorIdentity = UserId1,
                    PollType        = pollType,
                    MaxPoints       = maxPoints,
                    MaxPerVote      = maxPerVote,
                    InviteOnly      = inviteOnly,
                    NamedVoting     = namedVoting,
                    ExpiryDateUtc   = expiryDateUtc,
                    ChoiceAdding    = optionAdding
                };

                var dbPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    existingPoll
                };

                IContextFactory     mockContextFactory = CreateContextFactory(dbPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = pollId
                };


                controller.Copy(request);

                List <Poll> polls      = dbPolls.ToList();
                Poll        copiedPoll = polls[1];


                Assert.AreEqual(creator, copiedPoll.Creator);
                Assert.AreEqual(UserId1, copiedPoll.CreatorIdentity);
                Assert.AreEqual(pollType, copiedPoll.PollType);
                Assert.AreEqual(maxPoints, copiedPoll.MaxPoints);
                Assert.AreEqual(maxPerVote, copiedPoll.MaxPerVote);
                Assert.AreEqual(inviteOnly, copiedPoll.InviteOnly);
                Assert.AreEqual(namedVoting, copiedPoll.NamedVoting);
                Assert.AreEqual(expiryDateUtc, copiedPoll.ExpiryDateUtc);
                Assert.AreEqual(optionAdding, copiedPoll.ChoiceAdding);
            }
Beispiel #3
0
        public void PostTests()
        {
            // ARRANGE
            var controller = new PeopleSearch.Web.Controllers.API.PersonController(_personRepository);
            var dtoPerson  = new BigCompany.Contracts.Person()
            {
                DateOfBirth = new DateTime(1985, 5, 22),
                FirstName   = "UniqueString",
                LastName    = "Last",
                ImageBase64 = "test",
                Interests   = new[] { "Snowboarding", "Skydiving", "Faberge Eggs" }
            };

            // ACT
            controller.Post(dtoPerson);

            // ASSERT
            _persons.ToList().Any(x => x.FirstName == "UniqueString").Should().BeTrue();
            _mockContext.Verify(x => x.SaveChanges());
        }
Beispiel #4
0
            public void NewPollNameIsOldPollNamePrependedWithCopyOf()
            {
                const string pollName       = "Where shall we go today?";
                const string copiedPollName = "Copy of Where shall we go today?";

                Guid pollId = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");

                var existingPoll = new Poll()
                {
                    CreatorIdentity = UserId1, UUID = pollId, Name = pollName
                };

                var dbPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    existingPoll
                };

                IContextFactory     mockContextFactory = CreateContextFactory(dbPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = pollId
                };


                controller.Copy(request);

                List <Poll> polls      = dbPolls.ToList();
                Poll        copiedPoll = polls[1];


                Assert.AreEqual(copiedPollName, copiedPoll.Name);
            }
Beispiel #5
0
            public void CopiedPollHasSameChoicesAsOriginal()
            {
                Guid pollId = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");

                var options = new List <Choice>()
                {
                    new Choice()
                    {
                        Name        = "One",
                        Description = "Choice 1"
                    },
                    new Choice()
                    {
                        Name        = "Two",
                        Description = "Choice 2"
                    },
                    new Choice()
                    {
                        Name        = "Three",
                        Description = "Choice 3"
                    }
                };

                var existingPoll = new Poll()
                {
                    UUID            = pollId,
                    CreatorIdentity = UserId1,
                    Choices         = options
                };

                var dbPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    existingPoll
                };

                IContextFactory     mockContextFactory = CreateContextFactory(dbPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = pollId
                };


                controller.Copy(request);

                List <Poll>   polls = dbPolls.ToList();
                List <Choice> originalPollChoices = polls[0].Choices;
                List <Choice> copiedPollChoices   = polls[1].Choices;


                Assert.AreEqual(originalPollChoices[0].Name, copiedPollChoices[0].Name);
                Assert.AreEqual(originalPollChoices[0].Description, copiedPollChoices[0].Description);

                Assert.AreEqual(originalPollChoices[1].Name, copiedPollChoices[1].Name);
                Assert.AreEqual(originalPollChoices[1].Description, copiedPollChoices[1].Description);

                Assert.AreEqual(originalPollChoices[2].Name, copiedPollChoices[2].Name);
                Assert.AreEqual(originalPollChoices[2].Description, copiedPollChoices[2].Description);
            }