예제 #1
0
 public ScriptController(IUserScriptsService userScriptsService,
                         IScriptRunnerService scriptRunnerService,
                         IScriptRunEmailBuilder scriptRunEmailBuilder,
                         IEmailService emailService)
 {
     _userScriptsService    = userScriptsService;
     _scriptRunnerService   = scriptRunnerService;
     _scriptRunEmailBuilder = scriptRunEmailBuilder;
     _emailService          = emailService;
 }
            public void SetUp()
            {
                _scriptsRepositoryMock = new Mock <IScriptsRepository>();
                _scriptsRepositoryMock.Setup(o => o.GetAll()).Returns(new List <ScriptModel>
                {
                    new ScriptModel {
                        Key = "test-script-1"
                    },
                    new ScriptModel {
                        Key = "test-script-2"
                    },
                    new ScriptModel {
                        Key = "test-script-3"
                    },
                    new ScriptModel {
                        Key = "test-script-4"
                    },
                    new ScriptModel {
                        Key = "test-script-5"
                    },
                });

                _authorizationsRepositoryMock = new Mock <IAuthorizationsRepository>();
                _authorizationsRepositoryMock.Setup(o => o.GetAll()).Returns(new List <AuthorizationModel>
                {
                    new AuthorizationModel {
                        Target = "user-1", Type = AuthorizationType.User, Scripts = new List <string>
                        {
                            "test-script-1"
                        }
                    },
                    new AuthorizationModel {
                        Target = "group-1", Type = AuthorizationType.Group, Scripts = new List <string>
                        {
                            "test-script-2", "test-script-3"
                        }
                    },
                    new AuthorizationModel {
                        Target = "group-2", Type = AuthorizationType.Group, Scripts = new List <string>
                        {
                            "test-script-3", "test-script-4", "test-script-5"
                        }
                    },
                });

                _userScriptsService = new UserScriptsService(_scriptsRepositoryMock.Object,
                                                             _authorizationsRepositoryMock.Object);
            }