コード例 #1
0
        public void Execute_NullSourceModel_ThrowsException()
        {
            var mockSourceRepository = new Mock <ISourceRepository>();
            var createSourceCommand  = new CreateSourceCommand(mockSourceRepository.Object);

            Assert.Throws <ArgumentNullException>(() => createSourceCommand.Execute(null));
        }
コード例 #2
0
        public void Execute_AddsSourceToDatabase()
        {
            var mockSourceRepository = new Mock <ISourceRepository>();
            var createSourceCommand  = new CreateSourceCommand(mockSourceRepository.Object);
            var sourceModel          = new SourceModel();

            createSourceCommand.Execute(sourceModel);
            mockSourceRepository.Verify(r => r.Add(It.IsAny <Source>()), Times.Once);
        }