Esempio n. 1
0
        public async void PostRight_WhenIdAndBase64Provided_ShoulReturnHttp201()
        {
            // Arrange
            int id              = 1;
            var requestUrl      = $"v1/Diff/{id}/right";
            var differenceRight = new DifferenceRight(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZSIKfQ==");

            // Act
            var response = await _client.PostAsync(requestUrl, ContentHelper.GetStringContent(differenceRight));

            // Assert
            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
        }
        public void Add_WhenLeftSizeIs8001_ShouldThrowException()
        {
            //arrange
            _context.Database.EnsureCreated();
            var differenceRightRepository = new DifferenceRightRepository(_context);
            int id = 1;

            //Act
            var difference = new DifferenceRight(id, new string('a', 8001));

            differenceRightRepository.Add(difference);

            //Assert
            Exception ex = Assert.Throws <DbUpdateException>(() => differenceRightRepository.Add(difference));
        }
        public async void GetById_WhenProperlySaved_ShouldReturnEqualValues()
        {
            //arrange
            _context.Database.EnsureCreated();
            var differenceRightRepository = new DifferenceRightRepository(_context);
            int id = 1;

            //Act
            var differenceSaved = new DifferenceRight(id, "a");

            differenceRightRepository.Add(differenceSaved);

            var differenceReturned = await differenceRightRepository.GetById(id);

            //Assert
            Assert.Equal <Difference>(differenceSaved, differenceReturned);
        }
Esempio n. 4
0
        public async void GetDifferenceRight_WhenExists_ShoulReturnHttp200()
        {
            // Arrange
            int id              = 2;
            var postUrl         = $"v1/Diff/{id}/right";
            var differenceRight = new DifferenceRight(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZSIKfQ==");
            var content         = ContentHelper.GetStringContent(differenceRight);
            var postResponse    = await _client.PostAsync(postUrl, content);

            var requestUrl = postUrl;

            // Act
            var response = await _client.GetAsync(requestUrl);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            //TODO: Test for content
        }
Esempio n. 5
0
        public async void GetDifference_WhenEqualSizeButDifferentValues_ShoulReturnSameSizeButDifferentData()
        {
            // Arrange
            int id             = 3;
            var postUrlLeft    = $"v1/Diff/{id}/left";
            var differenceleft = new DifferenceLeft(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZSIKfQ==");
            var contentLeft    = ContentHelper.GetStringContent(differenceleft);
            await _client.PostAsync(postUrlLeft, contentLeft);

            var postUrlRight    = $"v1/Diff/{id}/right";
            var differenceRight = new DifferenceRight(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZTIiCn0=");
            var contentRight    = ContentHelper.GetStringContent(differenceRight);
            await _client.PostAsync(postUrlRight, contentRight);

            var requestUrl = $"v1/Diff/{id}";

            // Act
            var response = await _client.GetAsync(requestUrl);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            //TODO: Test for content
        }