Пример #1
0
        public void FailSavingNull()
        {
            var cdb = new CosmosDB();

            Assert.DoesNotThrow(() => cdb.OpenConnection());
            Assert.Catch(() => cdb.UpsertDocument(null, "flight").Wait());
        }
Пример #2
0
        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();
            });
        }
Пример #4
0
        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
                        });
                    }
                }
            });
        }