コード例 #1
0
        public void SwagOMeterAwardEngineShouldNotIncludeMultipleEntriesInTheWinners()
        {
            // Arrange
            var mockAttendee1 = new Mock<IAttendee>();
            var mockAttendee2 = new Mock<IAttendee>();
            var stubOriginalSwag = new Mock<ISwag>();
            stubOriginalSwag.SetupGet(s => s.Thing).Returns("SOCKS");
            stubOriginalSwag.SetupGet(s => s.Company).Returns("Company");
            var stubDuplicateSwag = new Mock<ISwag>();
            stubDuplicateSwag.SetupGet(s => s.Thing).Returns("SoCks");
            stubDuplicateSwag.SetupGet(s => s.Company).Returns("Company");

            var stubAttendees = new List<IAttendee> { mockAttendee1.Object, mockAttendee2.Object };
            var stubSwag = new List<ISwag> { stubOriginalSwag.Object, stubDuplicateSwag.Object };

            var stubAttendeeSource = new Mock<IAttendeeSource>();
            stubAttendeeSource.Setup(sa => sa.Load(It.IsAny<string>())).Returns(stubAttendees);

            var stubSwagSource = new Mock<ISwagSource>();
            stubSwagSource.Setup(ss => ss.Load(It.IsAny<string>())).Returns(stubSwag);

            // Act
            var awardEngine = new SwagOMeterAwardEngine(stubAttendeeSource.Object, stubSwagSource.Object);
            awardEngine.AwardSwag();
            awardEngine.AttendeeDoesNotWantSwag();

            // Assert
            Assert.IsTrue(awardEngine.CanSwag);
        }
コード例 #2
0
        public void SwagOMeterAwardEngineShouldNotBeAbleToSwagWhenTheLastAttendeeDoesntWantTheSwagAndTheOnlySwagLeftIsAnotherItemOfTheSame()
        {
            // Arrange
            var mockAttendee1 = new Mock<IAttendee>();
            var stubOriginalSwag = new Mock<ISwag>();
            stubOriginalSwag.SetupGet(s => s.Thing).Returns("SOCKS");
            stubOriginalSwag.SetupGet(s => s.Company).Returns("Company");
            var stubDuplicateSwag = new Mock<ISwag>();
            stubDuplicateSwag.SetupGet(s => s.Thing).Returns("SoCks");
            stubDuplicateSwag.SetupGet(s => s.Company).Returns("Company");

            var stubAttendees = new List<IAttendee> { mockAttendee1.Object };
            var stubSwag = new List<ISwag> { stubOriginalSwag.Object, stubDuplicateSwag.Object };

            var stubAttendeeSource = new Mock<IAttendeeSource>();
            stubAttendeeSource.Setup(sa => sa.Load(It.IsAny<string>())).Returns(stubAttendees);

            var stubSwagSource = new Mock<ISwagSource>();
            stubSwagSource.Setup(ss => ss.Load(It.IsAny<string>())).Returns(stubSwag);

            // Act
            var awardEngine = new SwagOMeterAwardEngine(stubAttendeeSource.Object, stubSwagSource.Object);
            awardEngine.AwardSwag();
            awardEngine.AttendeeDoesNotWantSwag();

            // Assert
            Assert.IsFalse(awardEngine.CanSwag);
        }
コード例 #3
0
        public void SwagOMeterAwardEngineShouldNotBeAbleToSwagWhenAnAttendeeDoesntWantTheSwagButNoOtherAttendeeOrSwagIsLeft()
        {
            // Arrange
            var stubAttendee = new Mock<IAttendee>();
            var stubSwagObject = new Mock<ISwag>();

            var stubAttendees = new List<IAttendee> { stubAttendee.Object };
            var stubSwag = new List<ISwag> { stubSwagObject.Object };

            var stubAttendeeSource = new Mock<IAttendeeSource>();
            stubAttendeeSource.Setup(sa => sa.Load(It.IsAny<string>())).Returns(stubAttendees);

            var stubSwagSource = new Mock<ISwagSource>();
            stubSwagSource.Setup(ss => ss.Load(It.IsAny<string>())).Returns(stubSwag);

            // Act
            var awardEngine = new SwagOMeterAwardEngine(stubAttendeeSource.Object, stubSwagSource.Object);
            awardEngine.AwardSwag();
            awardEngine.AttendeeDoesNotWantSwag();

            // Assert
            Assert.IsNull(awardEngine.WinningAttendee);
            Assert.IsNull(awardEngine.AwardedSwag);
            Assert.IsFalse(awardEngine.CanSwag);
        }
コード例 #4
0
        public void SwagOMeterAwardEngineShouldNotBeAbleToSwagWhenAnAttendeeDoesntWantTheSwagThenTheLastAttendeeWinsIt()
        {
            // Arrange
            var stubAttendee1 = new Mock<IAttendee>();
            stubAttendee1.SetupGet(a => a.Name).Returns("Bob");

            var stubAttendee2 = new Mock<IAttendee>();
            stubAttendee2.SetupGet(a => a.Name).Returns("Fred");

            var mockSwag = new Mock<ISwag>();
            mockSwag.SetupGet(a => a.Thing).Returns("Pants");

            var stubAttendees = new List<IAttendee> { stubAttendee1.Object, stubAttendee2.Object };
            var stubSwag = new List<ISwag> { mockSwag.Object };

            var stubAttendeeSource = new Mock<IAttendeeSource>();
            stubAttendeeSource.Setup(sa => sa.Load(It.IsAny<string>())).Returns(stubAttendees);

            var stubSwagSource = new Mock<ISwagSource>();
            stubSwagSource.Setup(ss => ss.Load(It.IsAny<string>())).Returns(stubSwag);

            // Act
            var awardEngine = new SwagOMeterAwardEngine(stubAttendeeSource.Object, stubSwagSource.Object);
            awardEngine.AwardSwag();
            awardEngine.AttendeeDoesNotWantSwag();
            awardEngine.AwardSwag();

            // Assert
            Assert.IsNotNull(awardEngine.WinningAttendee);
            Assert.AreEqual(mockSwag.Object, awardEngine.AwardedSwag);
            Assert.IsFalse(awardEngine.CanSwag);
        }
コード例 #5
0
        public void SwagOMeterAwardEngineShouldBeAbleToSwagWhenAnAttendeeDoesntWantTheSwagButAnotherAttendeeIsAvailableToWinIt()
        {
            // Arrange
            var mockAttendee1 = new Mock<IAttendee>();
            var mockAttendee2 = new Mock<IAttendee>();
            var mockSwag = new Mock<ISwag>();

            var stubAttendees = new List<IAttendee> { mockAttendee1.Object, mockAttendee2.Object };
            var stubSwag = new List<ISwag> { mockSwag.Object };

            var stubAttendeeSource = new Mock<IAttendeeSource>();
            stubAttendeeSource.Setup(sa => sa.Load(It.IsAny<string>())).Returns(stubAttendees);

            var stubSwagSource = new Mock<ISwagSource>();
            stubSwagSource.Setup(ss => ss.Load(It.IsAny<string>())).Returns(stubSwag);

            // Act
            var awardEngine = new SwagOMeterAwardEngine(stubAttendeeSource.Object, stubSwagSource.Object);
            awardEngine.AwardSwag();
            awardEngine.AttendeeDoesNotWantSwag();

            // Assert
            Assert.IsNull(awardEngine.WinningAttendee);
            Assert.IsNull(awardEngine.AwardedSwag);
            Assert.IsTrue(awardEngine.CanSwag);
        }