예제 #1
0
        public void patch_should_call_service()
        {
            // given
            var data = new UptimeCheckData()
            {
                Id          = Guid.NewGuid(),
                Name        = "Nom",
                Description = "Nomnom",
                Interval    = TimeSpan.FromHours(1),
                Properties  = new Dictionary <string, string>()
                {
                    { "key", "value" }
                }
            };

            var model = new UptimeCheckDataModel()
            {
                Id          = data.Id,
                Name        = data.Name,
                Description = data.Description,
                Interval    = data.Interval,
                //Properties = data.Properties
            };

            // when
            _controller.Patch(model);

            // then
            _checkServiceMock.Verify(x => x.Update(data));
        }
예제 #2
0
        public void post_should_call_service()
        {
            // given
            Guid expectedId = Guid.NewGuid();

            var data = new UptimeCheckData()
            {
                Id          = Guid.Empty,
                Name        = "Nom",
                Description = "Nomnom",
                Interval    = TimeSpan.FromHours(1),
                Properties  = new Dictionary <string, string>()
                {
                    { "key", "value" }
                }
            };

            var model = new UptimeCheckDataModel()
            {
                Id          = data.Id,
                Name        = data.Name,
                Description = data.Description,
                Interval    = data.Interval,
                //Properties = data.Properties
            };

            _checkServiceMock.Setup(x => x.Create(data)).Returns(expectedId);

            // when
            var actualId = _controller.Post(model);

            // then
            Assert.Equal(expectedId, actualId);
            _checkServiceMock.Verify(x => x.Create(data));
        }
예제 #3
0
        public Guid Post([FromBody] UptimeCheckDataModel model)
        {
            Guid id = _uptimeCheckService.Create(new UptimeCheckData()
            {
                Id          = Guid.NewGuid(),
                Name        = model.Name,
                Description = model.Description,
                Interval    = model.Interval,
                Properties  = new Dictionary <string, string>()
            });

            return(id);
        }
예제 #4
0
        public void Patch([FromBody] UptimeCheckDataModel model)
        {
            if (model.Id == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            _uptimeCheckService.Update(new UptimeCheckData()
            {
                Id          = model.Id.Value,
                Name        = model.Name,
                Description = model.Description,
                Interval    = model.Interval,
                Properties  = new Dictionary <string, string>()
            });
        }