public void TestCreatedServerWithJsonConnectionString()
        {
            const string server_connection_string = "{\"DbConnection\" : \"Server=54.228.253.62;Database=vmail;User ID=vmailadmin;Password=ESbWgt5Xym1SRjGfHL0rsi4VVZbldk;Pooling=True;Character Set=utf8\", " +
                                                    "\"Api\":{\"Protocol\":\"http\", \"Server\":\"54.228.253.62\", \"Port\":\"8081\", \"Version\":\"v1\",\"Token\":\"6ffcb0f58a3d950ee49104177f7f1d96\"}}";
            const int server_id = 3;
            const int tenant_id = 1;
            const string user_id = "some_user_id";

            var limits = new ServerLimits.Builder()
                        .SetMailboxMaxCountPerUser(2)
                        .Build();

            var setup = new ServerSetup
                .Builder(server_id, tenant_id, user_id)
                .SetConnectionString(server_connection_string)
                .SetServerLimits(limits)
                .Build();

            var serverBase = factory.CreateServer(setup);
            Assert.AreEqual(serverBase.Tenant, tenant_id);
            Assert.AreEqual(serverBase.User, user_id);
            Assert.AreEqual(serverBase.Id, server_id);
            Assert.AreEqual(serverBase.ConnectionString, server_connection_string);
            Assert.AreEqual(serverBase.Logger.GetType(), typeof(NullLogger));
            Assert.AreEqual(serverBase.SetupInfo.Limits, limits);
        }
        public virtual void TestCreatedServer()
        {
            var limits = new ServerLimits.Builder()
                        .SetMailboxMaxCountPerUser(2)
                        .Build();

            var setup = new ServerSetup
                .Builder(1, 3, "some_user_id")
                .SetConnectionString("server_connection")
                .SetServerLimits(limits)
                .Build();

            var serverBase = factory.CreateServer(setup);
            Assert.AreEqual(1, serverBase.Id);
            Assert.AreEqual(3, serverBase.Tenant);
            Assert.AreEqual("some_user_id", serverBase.User);
            Assert.AreEqual(serverBase.Logger.GetType(), typeof(NullLogger));
            Assert.AreEqual(serverBase.SetupInfo.Limits, limits);
        }
        public MailServerBase CreateServer()
        {
            var serverConnectionString = HttpUtility.UrlDecode(ConfigurationManager.AppSettings["ConnectionString"]);
            var tenantId = int.Parse(ConfigurationManager.AppSettings["TenantId"]);
            var userId = ConfigurationManager.AppSettings["TeamlabUserGuid"].ToString(CultureInfo.InvariantCulture);
            var serverId = int.Parse(ConfigurationManager.AppSettings["ServerId"]);
            var logger = LoggerFactory.GetLogger(LoggerFactory.LoggerType.Null, string.Empty);

            CoreContext.TenantManager.SetCurrentTenant(tenantId);

            var limits = new ServerLimits.Builder()
                        .SetMailboxMaxCountPerUser(10)
                        .Build();

            var setup = new ServerSetup
                .Builder(serverId, tenantId, userId)
                .SetConnectionString(serverConnectionString)
                .SetLogger(logger)
                .SetServerLimits(limits)
                .Build();

            return ServerFactory.CreateServer(setup);
        }
        private void RemoveDomain(int tenant, string user, int domainId)
        {
            var serverDal = new ServerDal(tenant);
            var serverData = serverDal.GetTenantServer();

            if ((ServerType) serverData.type != ServerType.Postfix) return;

            var mailserverfactory = new PostfixFactory();

            var setup = new ServerSetup
                .Builder(serverData.id, tenant, user)
                .SetConnectionString(serverData.connection_string)
                .SetLogger(_log)
                .Build();

            var mailServer = mailserverfactory.CreateServer(setup);

            var domain = mailServer.GetWebDomain(domainId, mailserverfactory);
            mailServer.DeleteWebDomain(domain, mailserverfactory);
        }