Exemplo n.º 1
0
        public async Task ShouldbeNotAddInvalidModelAsync()
        {
            var addResult = await Manager.AddAsync(((TModel)Config.CreateInvalidModel()));

            Assert.IsFalse(addResult.HasError, addResult.ErrorMessage);
            Assert.IsFalse(addResult.IsValid);
            Assert.IsNotEmpty(addResult.FailPropeties);
            Assert.IsTrue(addResult.WithErrors);
        }
Exemplo n.º 2
0
        public async Task ShouldAddWithByNullModelAsync()
        {
            var addResult = await Manager.AddAsync(null);

            Assert.IsTrue(addResult.HasError);
            Assert.IsNotEmpty(addResult.ErrorMessage);
            Assert.IsTrue(addResult.IsValid);
            Assert.IsEmpty(addResult.FailPropeties);
            Assert.IsTrue(addResult.WithErrors);
        }
Exemplo n.º 3
0
        public async Task ShouldAddWithoutErrorsAsync()
        {
            var oldModel  = Fixture.Create <TModel>();
            var addResult = await Manager.AddAsync(oldModel);

            Assert.IsFalse(addResult.HasError, addResult.ErrorMessage);
            Assert.IsTrue(addResult.IsValid);
            Assert.IsEmpty(addResult.FailPropeties);
            Assert.IsFalse(addResult.WithErrors);
        }
Exemplo n.º 4
0
        public async Task DeleteExistsModelAsync()
        {
            var model     = Fixture.Create <TModel>();
            var addResult = await Manager.AddAsync(model);

            Assert.IsFalse(addResult.HasError, addResult.ErrorMessage);

            var deleteResult = await Manager.DeleteAsync(model.Id);

            Assert.False(deleteResult.HasError, deleteResult.ErrorMessage);
        }
Exemplo n.º 5
0
        public async Task GetExistsModelAsync()
        {
            var model     = Fixture.Create <TModel>();
            var addResult = await Manager.AddAsync(model);

            Assert.IsFalse(addResult.HasError, addResult.ErrorMessage);

            var getResult = await Manager.GetAsync(model.Id);

            Assert.IsFalse(getResult.HasError, getResult.ErrorMessage);
            Assert.NotNull(getResult.Result);
        }
Exemplo n.º 6
0
        public async Task UpdateExistsModelAsync()
        {
            var model     = Fixture.Create <TModel>();
            var addResult = await Manager.AddAsync(model);

            Assert.IsFalse(addResult.HasError, addResult.ErrorMessage);

            var updateResult = await Manager.UpdateAsync(model);

            Assert.IsFalse(updateResult.HasError, updateResult.ErrorMessage);
            Assert.IsFalse(updateResult.WithErrors);
            Assert.IsTrue(updateResult.IsValid);
            Assert.IsEmpty(updateResult.FailPropeties);
        }
        public async Task I_d_like_to_add_dummy_key()
        {
            //given
            IManager service = new Manager(
                InputData.HostName,
                InputData.Port,
                InputData.ServiceHostName,
                Guid.NewGuid().ToString());

            var isConnected = service.IsConnected();

            //when
            var isAdded = await service.AddAsync("foo", "bar");

            var getValue = await service.GetAsync("foo");

            //then
            Assert.IsTrue(isConnected);
            Assert.IsTrue(isAdded);
            Assert.AreEqual(getValue, "bar");
        }
        public virtual async Task <HttpResponseMessage> CreateAsync([Validator(ValidationMode.Add)] TModel model)
        {
            model.Id = await Manager.AddAsync(model);

            return(Request.CreateResponse(HttpStatusCode.OK, model));
        }