示例#1
0
        public async Task ItShouldGetModelFromCache()
        {
            var cachedModel = new ModelMock();

            var metaService = new MetaService(
                new MetaRepositoryMock(),
                new ModelLoaderMock(),
                new ModelCacheMock(cachedModel)
                );

            var result = await metaService.GetModel(cachedModel.Name, CancellationToken.None);

            result.Should().BeSameAs(cachedModel);
        }
示例#2
0
        public async Task ItShouldLoadModelIfNotFromCache()
        {
            var model = new ModelMock();

            var metaService = new MetaService(
                new MetaRepositoryMock(new PropertyBag()),
                new ModelLoaderMock(model),
                new ModelCacheMock(putAsserts: m => { m.Should().BeSameAs(model); })
                );

            var result = await metaService.GetModel(model.Name, CancellationToken.None);

            result.Should().BeSameAs(model);
        }
示例#3
0
        public async void TestUpdate500()
        {
            var guid      = Guid.NewGuid();
            var modelMock = new ModelMock()
            {
                Id = guid
            };

            _service.Setup(s => s.UpdateAsync(modelMock)).Throws(new Exception());

            var response = await _controller.Update(modelMock.Id.ToString(), modelMock);

            Assert.Equal(500, response.StatusCode);
        }
示例#4
0
        public async void TestCreate()
        {
            var guid      = Guid.NewGuid();
            var modelMock = new ModelMock()
            {
                Id = guid
            };

            _service.Setup(s => s.AddAsync(modelMock)).Returns(Task.FromResult(modelMock));

            var response = await _controller.Create(modelMock);

            Assert.Equal(201, response.StatusCode);
            Assert.Equal(modelMock, response.Value);
        }
示例#5
0
        public async void TestFind()
        {
            var guid      = Guid.NewGuid();
            var id        = guid.ToString();
            var modelMock = new ModelMock()
            {
                Id = guid
            };

            _service.Setup(s => s.FindAsync(id)).Returns(Task.FromResult(modelMock));

            var response = await _controller.Find(id);

            Assert.Equal(200, response.StatusCode);
            Assert.Equal(modelMock, response.Value);
        }
示例#6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Simulacion simu = new Simulacion();

            simu.Nombre   = "Test Simulacion";
            simu.Duracion = 30;
            ModelMock mo = new ModelMock();

            mo.MockResultados();
            simu.TrazaSimulada = mo.Traza;
            ReportGraphsForm frm = new ReportGraphsForm(new SimulacionesListForm(), simu);

            frm.ShowDialog();
        }
示例#7
0
 public void Init()
 {
     _modelMock = new ModelMock();
 }