Ejemplo n.º 1
0
        public void Can_update_admin_ip_regulation()
        {
            /*** Arrange ***/
            var ipAddress = TestDataGenerator.GetRandomIpAddress();

            var adminIpRegulation = new AddBackendIpRegulationData
            {
                IpAddress = ipAddress
            };

            _backendService.CreateIpRegulation(adminIpRegulation);

            var regulation      = _backendService.GetIpRegulations().SingleOrDefault(ip => ip.IpAddress == ipAddress);
            var editIpAddress   = TestDataGenerator.GetRandomIpAddress();
            var editDescription = TestDataGenerator.GetRandomString(20);

            regulation.IpAddress   = editIpAddress;
            regulation.Description = editDescription;

            var updateRegulationData = Mapper.DynamicMap <EditBackendIpRegulationData>(regulation);

            /*** Act ***/
            _backendService.UpdateIpRegulation(updateRegulationData);

            /*** Assert ***/
            var updatedRegulation = _backendService.GetIpRegulations().SingleOrDefault(ip => ip.IpAddress == editIpAddress);

            Assert.IsNotNull(updatedRegulation);
            Assert.AreEqual(updatedRegulation.IpAddress, editIpAddress);
            Assert.AreEqual(updatedRegulation.Description, editDescription);
        }
        public void Cannot_execute_BackendIpRegulationService_without_permissions()
        {
            /* Arrange */
            LogWithNewAdmin(Modules.PlayerManager, Permissions.View);

            /* Act */
            Assert.Throws <InsufficientPermissionsException>(() => _backendService.GetIpRegulations());
            Assert.Throws <InsufficientPermissionsException>(() => _backendService.CreateIpRegulation(new AddBackendIpRegulationData()));
            Assert.Throws <InsufficientPermissionsException>(() => _backendService.UpdateIpRegulation(new EditBackendIpRegulationData()));
            Assert.Throws <InsufficientPermissionsException>(() => _backendService.DeleteIpRegulation(new Guid()));
        }