Esempio n. 1
0
        private void btSincronizar_Click(object sender, EventArgs e)
        {
            btCancelar.Enabled = false;

            var txts = new ArrayList()
            {
                "Sincronizando", "Sincronizando.", "Sincronizando.."
            };

            lblSincronizar.Visible = true;

            for (var i = 0; i < 5; i++)
            {
                lblSincronizar.Text = (string)txts[i - 3 * ((int)(i / 3))];
                lblSincronizar.Refresh();

                progressBar1.Value = i * 4;

                Thread.Sleep(200);
            }

            DummyServices.Init();
            var lista = new ListServicios();

            lista.Show();
            Close();
        }
 public void GetRatingsByUserShouldReturnNotFoundWithInvalidId()
 {
     MyWebApi
     .Controller <UserRatingsController>()
     .WithResolvedDependencies(DummyServices.GetDummyUserRatingsService())
     .Calling(c => c.GetRatingsForUser("Not-availableId"))
     .ShouldReturn()
     .NotFound();
 }
 public void GettingAllImagesShouldReturnAList()
 {
     MyWebApi
     .Controller <ImagesController>()
     .WithResolvedDependencies(DummyServices.GetDummyImagesService())
     .Calling(c => c.Get())
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <List <ImageResponseModel> >()
     .Passing(c => c.Count == DummyRepositories.NumberOfTestObjects);
 }
 public void GetMethodShouldReturnAListOfCountries()
 {
     MyWebApi
     .Controller <CountriesController>()
     .WithResolvedDependencies(DummyServices.GetDummyCountriesService())
     .Calling(c => c.Get())
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <IQueryable <CountryResponseModel> >()
     .Passing(r => r.Count() == DummyRepositories.NumberOfTestObjects);
 }
 public void GetByIdShouldReturnTheProperContracts()
 {
     MyWebApi
     .Controller <ContractsController>()
     .WithResolvedDependencies(DummyServices.GetDummyContractsService())
     .Calling(c => c.GetContractById(4))
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <ContractResponseModel>()
     .Passing(c => c.Id == 4);
 }
 public void GetRatingsByUserShouldReturnTheProperRatings()
 {
     MyWebApi
     .Controller <UserRatingsController>()
     .WithResolvedDependencies(DummyServices.GetDummyUserRatingsService())
     .Calling(c => c.GetRatingsForUser("TestId3"))
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <IQueryable <UserRatingResponseModel> >()
     .Passing(r => r.Count() == DummyRepositories.NumberOfTestObjects / 2);
 }
        public async Task GettingImagesForUserShouldReturnAList()
        {
            var result = await MyWebApi
                         .Controller <ImagesController>()
                         .WithResolvedDependencies(DummyServices.GetDummyImagesService())
                         .Calling(c => c.Get("1"))
                         .ShouldReturn()
                         .ResultOfType <Task <IHttpActionResult> >()
                         .AndProvideTheModel();

            //.WithResponseModelOfType<List<ImageResponseModel>>()
            //.Passing(c => c.Count == 1 && c[0].UserId == "1");
        }
 public void AddRatingShouldAddARatingAndReturnItsInt()
 {
     MyWebApi
     .Controller <UserRatingsController>()
     .WithResolvedDependencies(DummyServices.GetDummyUserRatingsService())
     .Calling(c => c.AddRating(new UserRatingResponseModel
     {
         ClientId = "Test",
         HitmanId = "Test2",
         Rating   = 1
     }))
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <int>()
     .Passing(r => r == DummyRepositories.NumberOfTestObjects - 1);
 }
        public async Task DeletingImagesShouldWorkCorrectly()
        {
            var dummyImageService  = DummyServices.GetDummyImagesService();
            var currentImagesCount = dummyImageService.All().Count();

            var result = await MyWebApi
                         .Controller <ImagesController>()
                         .WithResolvedDependencies(dummyImageService)
                         .Calling(c => c.Delete(3))
                         .ShouldReturn()
                         .ResultOfType <Task <IHttpActionResult> >()
                         .AndProvideTheModel();

            var newImageCount = dummyImageService.All().Count();

            Assert.IsTrue(newImageCount == currentImagesCount - 1);
        }
        public async Task PostingImagesShouldCreateAnImageAndReturnItsId()
        {
            Random random = new Random();

            var result = await MyWebApi
                         .Controller <ImagesController>()
                         .WithResolvedDependencies(DummyServices.GetDummyImagesService())
                         .Calling(c => c.Post(new ImageRequestModel()
            {
                Name      = "SUPER COOL TEST IMAGE",
                Extension = "gif",
                Data      = "R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
                UserId    = "1",
            }))
                         .ShouldReturn()
                         .ResultOfType <Task <IHttpActionResult> >()
                         .AndProvideTheModel();

            //.WithResponseModelOfType<int>()
            //.Passing(c => c == DummyRepositories.NumberOfTestObjects + 1);
        }