public async void CreateReadUpdateDelete()
        {
            //Post
            var person     = _fixture.PersonList.ElementAt(3);
            var postResult = await _adminControllerQueryEntity.Post(person);

            Assert.NotNull(postResult);
            Assert.IsType <FirebaseObject <MockFirebasePerson> >(postResult);
            Assert.Equal(person.Name, postResult.Object.Name);

            //Get
            var getResult = await _adminControllerQueryEntity.Get(postResult.Key);

            Assert.NotNull(getResult);
            Assert.IsType <MockFirebasePerson>(getResult);
            Assert.Equal(person.Name, getResult.Name);

            //Put
            person.Name = "Johnathan Doe";
            person.Age  = 25;
            var putResult = await _adminControllerQueryEntity.Put(postResult.Key, person);

            Assert.NotNull(putResult);
            Assert.IsType <MockFirebasePerson>(putResult);

            getResult = await _adminControllerQueryEntity.Get(postResult.Key);

            Assert.NotNull(getResult);
            Assert.IsType <MockFirebasePerson>(getResult);
            Assert.Equal(person.Name, getResult.Name);
            Assert.Equal(person.Age, getResult.Age);
            Assert.Equal(person.Gender, getResult.Gender);

            //Delete
            await _adminControllerQueryEntity.Delete(postResult.Key);

            getResult = await _adminControllerQueryEntity.Get(postResult.Key);

            Assert.Null(getResult);
        }
Exemple #2
0
        public async Task <ActionResult> Put(string key, Auction auction)
        {
            var existing = await _auctionContext.GetByKeyAsync(key);

            if (null == existing)
            {
                return(this.NotFound($"{key} not found!"));
            }

            Auction result;

            if (this.IsAdministrator())
            {
                result = await _adminAuctionQuery.Put(key, auction);
            }
            else
            {
                result = await _userAuctionQuery.Put(key, auction);
            }
            return(null != result
                ? this.Ok(JsonConvert.SerializeObject(new FirebaseObject <Auction>(key, auction)))
                : this.InternalServerError(string.Empty));
        }