예제 #1
0
        public async Task StateChangeProcessor_CreateDocument()
        {
            var client = CreateMockClient(null);

            var processor = new StateChangeProcessor(client.Object, "db", "col");
            var logger    = new Mock <ILogger>();

            var updatedState = new DeviceState();

            updatedState.DeviceId = "device001";
            updatedState.Battery  = 1;

            var result = await processor.UpdateState(updatedState, logger.Object);

            DeviceState resultDoc = (dynamic)result.Resource;

            Assert.AreEqual("device001", resultDoc.DeviceId);
            Assert.AreEqual(1, resultDoc.Battery);
        }
        public async Task StateChangeProcessor_CreateDocument()
        {
            var client = CreateMockClient(null);

            var option = new StateChangeProcessorOptions {
                COSMOSDB_DATABASE_COL = "col", COSMOSDB_DATABASE_NAME = "db"
            };
            var processor = new StateChangeProcessor(client.Object, Options.Create <StateChangeProcessorOptions>(option));
            var logger    = new Mock <ILogger>();

            var updatedState = new DeviceState();

            updatedState.DeviceId = "device001";
            updatedState.Battery  = 1;

            var result = await processor.UpdateState(updatedState, logger.Object);

            DeviceState resultDoc = (dynamic)result.Resource;

            Assert.AreEqual("device001", resultDoc.DeviceId);
            Assert.AreEqual(1, resultDoc.Battery);
        }