コード例 #1
0
        public void Return_PlayTimeService_Instance_WhenParametersSetCorrectly()
        {
            // Arrange
            var playTimesRepoMock = new Mock <IEfRepository <PlayTime> >();
            var uowMock           = new Mock <ISaveContext>();

            // Act
            var playTimeService = new PlayTimeService(playTimesRepoMock.Object, uowMock.Object);

            // Assert
            Assert.IsNotNull(playTimeService);
        }
コード例 #2
0
        public void ReturnProper_UpdatePlayTime_ResultFromCommitMethod()
        {
            // Arrange
            var playTimesRepoMock = new Mock <IEfRepository <PlayTime> >();
            var uowMock           = new Mock <ISaveContext>();

            playTimesRepoMock.Setup(c => c.Update(It.IsAny <PlayTime>())).Verifiable();
            uowMock.Setup(u => u.Commit()).Returns(1);

            var playTimeService = new PlayTimeService(playTimesRepoMock.Object, uowMock.Object);

            // Act
            var result = playTimeService.Update(It.IsAny <PlayTime>());

            // Assert
            Assert.That(result.Equals(1));
        }
コード例 #3
0
        public void ReturnProper_PlayTime_Collection()
        {
            // Arrange
            var playTimesRepoMock = new Mock <IEfRepository <PlayTime> >();
            var uowMock           = new Mock <ISaveContext>();

            IEnumerable <PlayTime> collection = new List <PlayTime>();

            playTimesRepoMock.Setup(c => c.All).Returns(() =>
            {
                return(collection.AsQueryable());
            });

            var playTimeService = new PlayTimeService(playTimesRepoMock.Object, uowMock.Object);

            // Act
            IEnumerable <PlayTime> playTimes = playTimeService.GetAll();

            // Assert
            Assert.That(playTimes, Is.EqualTo(collection));
        }