Exemplo n.º 1
0
        private Mongoose.Ews.Server.Data.EwsServer BootstrapEwsServer(string serverName)
        {
            var type          = typeof(CustomEwsServiceHost);
            var className     = type.FullName;
            var assembleyFile = $"{type.Assembly.GetName().Name}.dll";

            using (var adapter = EwsServerDataAdapter.ConnectNew(serverName, EwsEndpoint, "MyRealm", UserName, Password, true, true, assembleyFile, className))
            {
                adapter.PurgeData();

                // If you use the Adapter to access your service, you will get standard behavior.
                var vi = adapter.ValueItems.FirstOrDefault(x => x.AlternateId == ServerHelper.CityId);
                Assert.IsNull(vi);

                // Let's add the ValueItem our custom SetValuesProcessor is targeting
                var addedVi = adapter.AddValueItem(ServerHelper.CityId, "City", null, EwsValueTypeEnum.String, EwsValueWriteableEnum.Writeable, EwsValueForceableEnum.NotForceable, EwsValueStateEnum.Good, null);
                Assert.That(addedVi.Value, Is.Null.Or.Empty);

                // Add CityNameId
                addedVi = adapter.AddValueItem(ServerHelper.CityNameId, "City Name", null, EwsValueTypeEnum.String, EwsValueWriteableEnum.ReadOnly, EwsValueForceableEnum.NotForceable, EwsValueStateEnum.Good, null);
                Assert.That(addedVi.Value, Is.Null.Or.Empty);
                Assert.AreEqual(EwsValueStateEnum.Good, addedVi.State);

                // Even though we told the Server to auto start, it isn't running.  Why?  Because we're in a test harness even if SmartConnector is running in the background.
                Assert.IsFalse(adapter.Server.IsRunning);

                return(adapter.Server);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// When the city is changed and/or we don't get a reply from the service, we don't know if the current ValueItem data is correct or not.
        /// Let's set the State to Uncertain.
        /// </summary>
        public static void MakeDataServedUncertain(EwsServerDataAdapter adapter, string cityName, string logCategory)
        {
            adapter.ModifyValueItemValue(CityNameId, cityName, EwsValueStateEnum.Uncertain);

            foreach (var id in VolatileValueItemIds)
            {
                // In case the ID doesn't resolve to a VI (as in UT environments), let's just log that condition.
                try
                {
                    adapter.ModifyValueItemState(id, EwsValueStateEnum.Uncertain);
                }
                catch (Exception ex)
                {
                    Logger.LogError(logCategory, ex);
                }
            }
        }
Exemplo n.º 3
0
        public void CreateNewEwsServerTest()
        {
            const string serverName = "Custom EWS Test Server";

            try
            {
                var server = BootstrapEwsServer(serverName);

                // Normally, the output of this assembly would be deployed to the SmartConnector service folder and SmartConnector would manage hosting the EWS Server endpoint.
                // Since we aren't doing that at the moment, we need to intervene on it's behalf so we can debug our custom controller.
                using (var host = new CustomEwsServiceHost(server))
                {
                    host.Open();

                    // But why is it still not "running"?
                    Assert.IsFalse(server.IsRunning);

                    // Because we're looking at a "stale" copy of the server.  Adapters shouldn't be kept open for long periods of time or may be looking at stale data.
                    // Let's reconnect
                    using (var adapter = EwsServerDataAdapter.ConnectExisting(serverName, UserName, Password))
                    {
                        server = adapter.Server;
                        // But it's still not running?  Unfortunately, the interaction to give this feedback IS managed by SmartConnector so even though we spun up an endpoint it's not reporting that.  Let's verify that.
                        Assert.IsFalse(server.IsRunning);
                        server = null;
                    }

                    // We can use EwsClient to communicate with our server though
                    TestServerWithEwsClient();

                    host.Close();
                }
            }
            finally
            {
                using (var adapter = EwsServerDataAdapter.ConnectExisting(serverName, UserName, Password))
                {
                    // Let's clean up after ourselves.
                    adapter.DeleteServer();
                }
            }
        }
Exemplo n.º 4
0
 protected override EwsServerDataAdapter CreateEwsServer()
 {
     return(EwsServerDataAdapter.ConnectNew(ServerName, EwsAddress, Realm, UserName, Password,
                                            true, true, "SmartConnector.WeatherExtension.dll", "SmartConnector.WeatherExtension.EwsServer.CustomEwsServiceHost"));
 }
 protected override EwsServerDataAdapter CreateEwsServer()
 {
     return(EwsServerDataAdapter.ConnectNew(ServerName, EwsAddress, "", UserName, Password,
                                            true, true, "Mongoose.Ews.Server.dll", "Mongoose.Ews.Server.MongooseEwsServiceHost"));
 }