public void TestCanViewSpecimenInheritNotInContacts()
        {
            var specimens = new List <Specimen>
            {
                new Specimen
                {
                    Id            = 1,
                    InventoryItem = new InventoryItem
                    {
                        Id         = 1,
                        Visibility = Visibility.Inherit,
                        User       = new User
                        {
                            InventoryItemVisibility = Visibility.Contacts,
                            Contacts = new List <UserContact>()
                            {
                                new UserContact
                                {
                                    Id            = 1,
                                    UserId        = 1,
                                    ContactUserId = 5
                                }
                            }
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visibleSpecimens = specimens.CanViewContent(user);

            visibleSpecimens.Should().HaveCount(0);
        }
        public void TestCanViewPublicSpecimenHiddenProfile()
        {
            var specimens = new List <Specimen>
            {
                new Specimen
                {
                    Id            = 1,
                    InventoryItem = new InventoryItem
                    {
                        Id         = 1,
                        Visibility = Visibility.Public,
                        User       = new User
                        {
                            ProfileVisibility = Visibility.Hidden
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visibleSpecimens = specimens.CanViewContent(user);

            visibleSpecimens.Should().HaveCount(1);
        }
Example #3
0
        public void TestCanViewActivityInContacts()
        {
            var activities = new List <Activity>
            {
                new Activity
                {
                    Id         = 1,
                    Visibility = Visibility.Contacts,
                    User       = new User
                    {
                        Contacts = new List <UserContact>()
                        {
                            new UserContact
                            {
                                Id            = 1,
                                UserId        = 1,
                                ContactUserId = 2
                            }
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visibleActivities = activities.CanViewContent(user);

            visibleActivities.Should().HaveCount(1);
        }
        public void TestCannotViewSpecimenNotInContacts()
        {
            var ownerUser = new User
            {
                Id       = 1,
                Contacts = new List <UserContact>()
            };
            var viewingUser = new EmergenceModels.User {
                Id = 2
            };
            var specimens = new List <Specimen>
            {
                new Specimen
                {
                    Id            = 1,
                    InventoryItem = new InventoryItem
                    {
                        Id         = 1,
                        Visibility = Visibility.Contacts,
                        User       = ownerUser
                    }
                }
            }.AsQueryable();

            var visibleSpecimens = specimens.CanViewContent(viewingUser);

            visibleSpecimens.Should().HaveCount(0);
        }
Example #5
0
        public void TestCanViewActivityProfileInheritNotInContacts()
        {
            var activities = new List <Activity>
            {
                new Activity
                {
                    Id         = 1,
                    Visibility = Visibility.Inherit,
                    User       = new User
                    {
                        ProfileVisibility  = Visibility.Contacts,
                        ActivityVisibility = Visibility.Inherit,
                        Contacts           = new List <UserContact>()
                        {
                            new UserContact
                            {
                                Id            = 1,
                                UserId        = 1,
                                ContactUserId = 5
                            }
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visibleActivitys = activities.CanViewContent(user);

            visibleActivitys.Should().HaveCount(0);
        }
Example #6
0
        public void TestCanViewOriginProfileInheritNotInContacts()
        {
            var origins = new List <Origin>
            {
                new Origin
                {
                    Id         = 1,
                    Visibility = Visibility.Inherit,
                    User       = new User
                    {
                        ProfileVisibility = Visibility.Contacts,
                        OriginVisibility  = Visibility.Inherit,
                        Contacts          = new List <UserContact>()
                        {
                            new UserContact
                            {
                                Id            = 1,
                                UserId        = 1,
                                ContactUserId = 5
                            }
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visibleOrigins = origins.CanViewContent(user);

            visibleOrigins.Should().HaveCount(0);
        }
Example #7
0
        public void TestCanViewPlantInfoProfileInheritNotInContacts()
        {
            var plantInfos = new List <PlantInfo>
            {
                new PlantInfo
                {
                    Id         = 1,
                    Visibility = Visibility.Inherit,
                    User       = new User
                    {
                        ProfileVisibility       = Visibility.Contacts,
                        InventoryItemVisibility = Visibility.Inherit,
                        Contacts = new List <UserContact>()
                        {
                            new UserContact
                            {
                                Id            = 1,
                                UserId        = 1,
                                ContactUserId = 5
                            }
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visiblePlantInfos = plantInfos.CanViewContent(user);

            visiblePlantInfos.Should().HaveCount(0);
        }
Example #8
0
        public void TestCanViewPlantInfoInContacts()
        {
            var plantInfos = new List <PlantInfo>
            {
                new PlantInfo
                {
                    Id         = 1,
                    Visibility = Visibility.Contacts,
                    User       = new User
                    {
                        Contacts = new List <UserContact>()
                        {
                            new UserContact
                            {
                                Id            = 1,
                                UserId        = 1,
                                ContactUserId = 2
                            }
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visiblePlantInfos = plantInfos.CanViewContent(user);

            visiblePlantInfos.Should().HaveCount(1);
        }
Example #9
0
        public void TestCanViewInventoryItemInheritInContacts()
        {
            var inventoryItems = new List <InventoryItem>
            {
                new InventoryItem
                {
                    Id         = 1,
                    Visibility = Visibility.Inherit,
                    User       = new User
                    {
                        InventoryItemVisibility = Visibility.Contacts,
                        Contacts = new List <UserContact>()
                        {
                            new UserContact
                            {
                                Id            = 1,
                                UserId        = 1,
                                ContactUserId = 2
                            }
                        }
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visibleInventoryItems = inventoryItems.CanViewContent(user);

            visibleInventoryItems.Should().HaveCount(1);
        }
Example #10
0
        public void TestCanViewPublicActivityHiddenActivities()
        {
            var activities = new List <Activity>
            {
                new Activity
                {
                    Id         = 1,
                    Visibility = Visibility.Public,
                    User       = new User
                    {
                        ActivityVisibility = Visibility.Hidden
                    }
                }
            }.AsQueryable();

            var user = new EmergenceModels.User {
                Id = 2
            };
            var visibleActivities = activities.CanViewContent(user);

            visibleActivities.Should().HaveCount(1);
        }
Example #11
0
        public void TestCannotViewActivityNotInContacts()
        {
            var ownerUser = new User
            {
                Id       = 1,
                Contacts = new List <UserContact>()
            };
            var viewingUser = new EmergenceModels.User {
                Id = 2
            };
            var activities = new List <Activity>
            {
                new Activity
                {
                    Id         = 1,
                    Visibility = Visibility.Contacts,
                    User       = ownerUser
                }
            }.AsQueryable();

            var visibleActivities = activities.CanViewContent(viewingUser);

            visibleActivities.Should().HaveCount(0);
        }
Example #12
0
        public void TestCannotViewOriginNotInContacts()
        {
            var ownerUser = new User
            {
                Id       = 1,
                Contacts = new List <UserContact>()
            };
            var viewingUser = new EmergenceModels.User {
                Id = 2
            };
            var origins = new List <Origin>
            {
                new Origin
                {
                    Id         = 1,
                    Visibility = Visibility.Contacts,
                    User       = ownerUser
                }
            }.AsQueryable();

            var visibleOrigins = origins.CanViewContent(viewingUser);

            visibleOrigins.Should().HaveCount(0);
        }
Example #13
0
        public void TestCannotViewPlantInfoNotInContacts()
        {
            var ownerUser = new User
            {
                Id       = 1,
                Contacts = new List <UserContact>()
            };
            var viewingUser = new EmergenceModels.User {
                Id = 2
            };
            var plantInfos = new List <PlantInfo>
            {
                new PlantInfo
                {
                    Id         = 1,
                    Visibility = Visibility.Contacts,
                    User       = ownerUser
                }
            }.AsQueryable();

            var visiblePlantInfos = plantInfos.CanViewContent(viewingUser);

            visiblePlantInfos.Should().HaveCount(0);
        }