public void FailSavingNull()
        {
            var cdb = new CosmosDB();

            Assert.DoesNotThrow(() => cdb.OpenConnection());
            Assert.Catch(() => cdb.UpsertDocument(null, "flight").Wait());
        }
        public void FailBadCollection()
        {
            var cdb = new CosmosDB();

            Assert.DoesNotThrow(() => cdb.OpenConnection());
            Assert.Catch(() => cdb.UpsertDocument(new object(), "badCollection").Wait());
        }
        public CosmosSaveActor(CosmosDB cosmos)
        {
            cdb = cosmos;

            Receive <CosmosSaveRequest>(r =>
            {
                cdb.UpsertDocument(r.SaveObject, "flights").Wait();
            });
        }
        public CosmosSaveActor(CosmosDB cdb)
        {
            cosmosDB = cdb;

            Receive <SaveRequest>(r =>
            {
                if (r.ToSave == null)
                {
                    Sender.Tell(new BadRequest()
                    {
                        BadToSave = true
                    });
                }
                else if (string.IsNullOrWhiteSpace(r.Collection))
                {
                    Sender.Tell(new BadRequest()
                    {
                        BadCollection = true, ToSave = r.ToSave
                    });
                }
                else
                {
                    try
                    {
                        cosmosDB.UpsertDocument(r.ToSave, r.Collection);
                    }
                    catch (Exception ex)
                    {
                        Sender.Tell(new FailedToSave()
                        {
                            Exception = ex, ToSave = r.ToSave
                        });
                    }
                }
            });
        }