Ejemplo n.º 1
0
        public void ShouldCallGetUsersByStatusTypeAndTitleOrSenderMethodFromUsersService(int roleType, string name)
        {
            // Arrange
            var mockedView = new Mock <IUsersView>();

            mockedView.Setup(v => v.Model).Returns(new UsersViewModel());

            var mockedUsersService = new Mock <IUsersService>();

            mockedUsersService.Setup(cs =>
                                     cs.GetUsersByRoleTypeAndName(It.IsAny <int>(),
                                                                  It.IsAny <string>()))
            .Verifiable();

            var usersPresenter = new UsersPresenter(mockedView.Object,
                                                    mockedUsersService.Object);

            // Act
            mockedView.Raise(v => v.FilterUsers += null,
                             new FilterEventArgs(roleType, name));

            // Assert
            mockedUsersService.Verify(cs =>
                                      cs.GetUsersByRoleTypeAndName(roleType, name),
                                      Times.Once);
        }
Ejemplo n.º 2
0
        public FormServer(ConnectionManager connectionMgr)
        {
            InitializeComponent();

            this.connectionMgr = connectionMgr;

            // initialize presenters
            mainPresenter        = new MainPresenter();
            userPresenter        = new UsersPresenter();
            groupPresenter       = new GroupsPresenter();
            monitorPresenter     = new MonitorsPresenter();
            applicationPresenter = new ApplicationsPresenter();
            connectionPresenter  = new ConnectionPresenter(this, connectionMgr);
            remoteVncPresenter   = new RemoteVncPresenter();
            visionInputPresenter = new VisionInputPresenter();

            // create right click menu
            ContextMenu menuContext = new ContextMenu();

            this.ContextMenu = menuContext;

            MenuItem mnuItemAbout = new MenuItem();

            mnuItemAbout.Text   = "About";
            mnuItemAbout.Click += mnuItemAbout_Click;
            menuContext.MenuItems.Add(mnuItemAbout);

            // tabControl.ImageList = new ImageList();
        }
Ejemplo n.º 3
0
        public void ShouldAssignToViewModelUsers_ReceivedFromCallGetUsersMethodFromContactsService()
        {
            // Arrange
            var users = new List <User>()
            {
                new User()
                {
                    Id = "42"
                },
                new User()
                {
                    Id = "24"
                }
            };
            var mockedView = new Mock <IUsersView>();

            mockedView.Setup(v => v.Model).Returns(new UsersViewModel());

            var mockedUsersService = new Mock <IUsersService>();

            mockedUsersService.Setup(cs => cs.GetUsers())
            .Returns(users)
            .Verifiable();

            var usersPresenter = new UsersPresenter(mockedView.Object,
                                                    mockedUsersService.Object);

            // Act
            mockedView.Raise(v => v.ListingUsers += null, new EventArgs());

            // Assert
            Assert.AreEqual(users, mockedView.Object.Model.Users);
        }
Ejemplo n.º 4
0
        public FormUsers()
        {
            InitializeComponent();
            Repository repository = new Repository();

            usersPresenter = new UsersPresenter(this, repository);
            usersPresenter.LoadUsers();
        }
Ejemplo n.º 5
0
        public void ShouldSubscribeToUsersViewOnFilteringUsersEvent()
        {
            // Arrange
            var mockedView         = new MockedUsersView();
            var mockedUsersService = new Mock <IUsersService>();

            // Act
            var usersPresenter = new UsersPresenter(mockedView,
                                                    mockedUsersService.Object);

            // Assert
            Assert.IsTrue(mockedView.IsSubscribedMethod("OnFilteringUsers"));
        }
Ejemplo n.º 6
0
        public void ShouldCreateAnInstanceInheritingPresenter_WhenValidUsersServiceIsPassed()
        {
            // Arrange
            var mockedView         = new Mock <IUsersView>();
            var mockedUsersService = new Mock <IUsersService>();

            // Act
            var usersPresenter = new UsersPresenter(mockedView.Object,
                                                    mockedUsersService.Object);

            // Assert
            Assert.IsInstanceOf <Presenter <IUsersView> >(usersPresenter);
        }
Ejemplo n.º 7
0
        public void ShouldCallGetUsersMethodFromUsersService()
        {
            // Arrange
            var mockedView = new Mock <IUsersView>();

            mockedView.Setup(v => v.Model).Returns(new UsersViewModel());

            var mockedUsersService = new Mock <IUsersService>();

            mockedUsersService.Setup(cs => cs.GetUsers()).Verifiable();

            var usersPresenter = new UsersPresenter(mockedView.Object,
                                                    mockedUsersService.Object);

            // Act
            mockedView.Raise(v => v.ListingUsers += null, new EventArgs());

            // Assert
            mockedUsersService.Verify(cs => cs.GetUsers(), Times.Once);
        }
Ejemplo n.º 8
0
        public void ShouldAssignViewModelWithUsers_ReceivedFromGetUsersByStatusTypeAndTitleOrSender(int roleType, string search)
        {
            // Arrange
            var users = new List <User>()
            {
                new User()
                {
                    Id = "12"
                },
                new User()
                {
                    Id = "3"
                }
            };

            var mockedView = new Mock <IUsersView>();

            mockedView.Setup(v => v.Model).Returns(new UsersViewModel());

            var mockedUsersService = new Mock <IUsersService>();

            mockedUsersService.Setup(cs =>
                                     cs.GetUsersByRoleTypeAndName(It.IsAny <int>(),
                                                                  It.IsAny <string>()))
            .Returns(users)
            .Verifiable();

            var usersPresenter = new UsersPresenter(mockedView.Object,
                                                    mockedUsersService.Object);

            // Act
            mockedView.Raise(v => v.FilterUsers += null,
                             new FilterEventArgs(roleType, search));

            // Assert
            CollectionAssert.AreEquivalent(users, mockedView.Object.Model.Users);
        }
Ejemplo n.º 9
0
        public FormRemoteConfigure()
        {
            InitializeComponent();
            this.Load        += FormRemoteConfigure_Load;
            this.FormClosing += FormRemoteConfigure_FormClosing;

            remoteVncPresenter   = new RemoteVncPresenter();
            applicationPresenter = new ApplicationsPresenter();
            groupPresenter       = new GroupsPresenter();
            userPresenter        = new UsersPresenter();
            visionInputPresenter = new VisionInputPresenter();
            monitorPresenter     = new MonitorsPresenter();

            // create right click menu
            ContextMenu menuContext = new ContextMenu();

            this.ContextMenu = menuContext;

            MenuItem mnuItemAbout = new MenuItem();

            mnuItemAbout.Text   = "About";
            mnuItemAbout.Click += mnuItemAbout_Click;
            menuContext.MenuItems.Add(mnuItemAbout);
        }
Ejemplo n.º 10
0
 protected override void OnPreInit(EventArgs e)
 {
     base.OnPreInit(e);
     _presenter = new UsersPresenter(this);
     _presenter.Init();
 }
Ejemplo n.º 11
0
 public void SetUp()
 {
     _view      = new Mock <IUsersView>();
     _presenter = new UsersPresenter(_view.Object);
 }