示例#1
0
        public void FindAllApplications_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory      = new AccessorFactory();
            var applicationsAccessor = accessorFactory.CreateAccessor <IApplicationsAccessor>();
            var DatabaseMock         = new DatabaseMock();

            DatabaseMock.SeedDatabase();

            // Act
            var result = applicationsAccessor.FindAllApplications();

            // Assert
            Assert.NotEmpty(result);
        }
示例#2
0
        public void FindAllUsersForApplication_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory      = new AccessorFactory();
            var applicationsAccessor = accessorFactory.CreateAccessor <IApplicationsAccessor>();
            var DatabaseMock         = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            string applicationName = DatabaseMock.GetValue("applicationName");

            // Act
            var result = applicationsAccessor.FindAllUsersForApplication(applicationName);

            // Assert
            Assert.NotEmpty(result);
        }
示例#3
0
        public void DeleteApplication_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory      = new AccessorFactory();
            var applicationsAccessor = accessorFactory.CreateAccessor <IApplicationsAccessor>();
            var DatabaseMock         = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var applicationId = DatabaseMock.GetId("applicationId");

            // Act
            applicationsAccessor.DeleteApplication(applicationId);

            // Assert
            Assert.Null(applicationsAccessor.Find(applicationId));
        }
示例#4
0
        public void Find_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory      = new AccessorFactory();
            var applicationsAccessor = accessorFactory.CreateAccessor <IApplicationsAccessor>();
            var DatabaseMock         = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var applicationId = DatabaseMock.GetId("applicationId");

            // Act
            var result = applicationsAccessor.Find(applicationId);

            // Assert
            Assert.Equal(expected: applicationId, actual: result.Id);
        }
示例#5
0
        public void DeleteClaim_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory = new AccessorFactory();
            var claimsAccessor  = accessorFactory.CreateAccessor <IClaimsAccessor>();
            var DatabaseMock    = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var claimId = DatabaseMock.GetId("claimId");

            // Act
            claimsAccessor.DeleteClaim(claimId);

            // Assert
            Assert.Null(claimsAccessor.Find(claimId));
        }
示例#6
0
        public void FindAllUserClaims_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory    = new AccessorFactory();
            var userClaimsAccessor = accessorFactory.CreateAccessor <IUserClaimsAccessor>();
            var DatabaseMock       = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var userId = DatabaseMock.GetId("userId");

            // Act
            var result = userClaimsAccessor.FindAllUserClaims(userId);

            // Assert
            Assert.NotEmpty(result);
        }
        public void GetApplicationUsers_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var managerFactory = new ManagerFactory();
            var manager        = managerFactory.CreateManager <IApplicationManager>();
            var DatabaseMock   = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            string applicationName = DatabaseMock.GetValue("applicationName");

            // Act
            var result = manager.GetApplicationUsers(applicationName);

            // Assert
            Assert.NotEmpty(result);
        }
        public void GetUser_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var managerFactory = new ManagerFactory();
            var manager        = managerFactory.CreateManager <IApplicationManager>();
            var DatabaseMock   = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var userId = DatabaseMock.GetId("userId");

            // Act
            var result = manager.GetUser(userId);

            // Assert
            Assert.NotEmpty(result.Applications);
        }
        public void RemoveApplication_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var managerFactory = new ManagerFactory();
            var manager        = managerFactory.CreateManager <IApplicationManager>();
            var DatabaseMock   = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var    applicationId   = DatabaseMock.GetId("applicationId");
            string applicationName = DatabaseMock.GetValue("applicationName");

            // Act
            manager.RemoveApplication(applicationId);

            // Assert
            Assert.Null(manager.GetApplicationUsers(applicationName));
        }
示例#10
0
        public void RemoveApplication_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            ActorSystem actorSystem            = ActorSystem.Create("TestActorSystem");
            Props       actorRouter            = Props.Create <ApplicationsActor>().WithRouter(new RoundRobinPool(5));
            IActorRef   actorPool              = actorSystem.ActorOf(actorRouter, "Test");
            var         applicationsController = new ApplicationsController(actorPool);
            var         DatabaseMock           = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var applicationId = DatabaseMock.GetId("applicationId");

            // Act
            var result = applicationsController.RemoveApplication(applicationId).Result;

            // Assert
            Assert.IsType <AcceptedResult>(result);
        }
示例#11
0
        public void AddApplication_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            ActorSystem actorSystem            = ActorSystem.Create("TestActorSystem");
            Props       actorRouter            = Props.Create <ApplicationsActor>().WithRouter(new RoundRobinPool(5));
            IActorRef   actorPool              = actorSystem.ActorOf(actorRouter, "Test");
            var         applicationsController = new ApplicationsController(actorPool);
            var         DatabaseMock           = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            string applicationName = DatabaseMock.GetValue("applicationName");

            // Act
            var result = applicationsController.AddApplication(applicationName).Result;

            // Assert
            Assert.NotNull(result.Value);
        }
示例#12
0
        public void GetUser_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            ActorSystem actorSystem            = ActorSystem.Create("TestActorSystem");
            Props       actorRouter            = Props.Create <ApplicationsActor>().WithRouter(new RoundRobinPool(5));
            IActorRef   actorPool              = actorSystem.ActorOf(actorRouter, "Test");
            var         applicationsController = new ApplicationsController(actorPool);
            var         DatabaseMock           = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var userId = DatabaseMock.GetId("userId");

            // Act
            var result = applicationsController.GetUser(userId).Result;

            // Assert
            Assert.NotNull(result.Value.Applications);
        }
示例#13
0
        public void DeleteMembership_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory     = new AccessorFactory();
            var membershipsAccessor = accessorFactory.CreateAccessor <IMembershipsAccessor>();
            var DatabaseMock        = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var membershipId = DatabaseMock.GetId("membershipId");
            var userId       = DatabaseMock.GetId("userId");

            // Act
            membershipsAccessor.DeleteMembership(membershipId);
            var result = membershipsAccessor.FindAllUserApplications(userId).Where(membership => membership.Id == membershipId);

            // Assert
            Assert.Empty(result);
        }
示例#14
0
        public void SaveClaim_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory = new AccessorFactory();
            var claimsAccessor  = accessorFactory.CreateAccessor <IClaimsAccessor>();
            var DatabaseMock    = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var id    = DatabaseMock.GetId("Applications");
            var claim = new Claim
            {
                Id            = Guid.NewGuid(),
                ApplicationId = id,
                ClaimType     = Guid.NewGuid().ToString(),
                ClaimValue    = Guid.NewGuid().ToString()
            };

            // Act
            var result = claimsAccessor.SaveClaim(claim);

            // Assert
            Assert.NotNull(result);
        }
示例#15
0
        public void SaveUserClaim_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory    = new AccessorFactory();
            var userClaimsAccessor = accessorFactory.CreateAccessor <IUserClaimsAccessor>();
            var DatabaseMock       = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var claimId   = DatabaseMock.GetId("claimId");
            var userId    = DatabaseMock.GetId("userId");
            var userClaim = new UserClaim
            {
                Id      = Guid.NewGuid(),
                ClaimId = claimId,
                UserId  = userId
            };

            // Act
            var result = userClaimsAccessor.SaveUserClaim(userClaim);

            // Assert
            Assert.NotNull(result);
        }
示例#16
0
        public void SaveMembership_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var accessorFactory     = new AccessorFactory();
            var membershipsAccessor = accessorFactory.CreateAccessor <IMembershipsAccessor>();
            var DatabaseMock        = new DatabaseMock();

            DatabaseMock.SeedDatabase();
            var applicationId = DatabaseMock.GetId("applicationId");
            var userId        = DatabaseMock.GetId("userId");
            var membership    = new Membership
            {
                Id            = Guid.NewGuid(),
                ApplicationId = applicationId,
                UserId        = userId
            };

            // Act
            var result = membershipsAccessor.SaveMembership(membership);

            // Assert
            Assert.NotNull(result);
        }