Example #1
0
        public void SetRotor_Should_When()
        {
            // Arrange
            var      enigmaController = new EnigmaController();
            RotorDto rotorDto         = new RotorDto {
                Mapping = "bdfhjlcprtxvznyeiwgakmusqo",
                Rotate  = true,
                AdjacentRotorAdvanceOffset = 21,
                InitialDialSetting         = 'z'
            };

            // Act
            //HttpResponseMessage response = enigmaController.SetRotor(rotorDto, 3);
            enigmaController.SetPlugboard

            // Assert
        }
Example #2
0
        public HttpResponseMessage SetRotor([FromBody] RotorDto rotorDto, [FromUri] int id)
        {
            HttpResponseMessage response;

            string json = JsonConvert.SerializeObject(rotorDto, Formatting.Indented);

            try
            {
                staticEnigmaMachine.SetRotorDial(id, rotorDto.InitialDialSetting);
                response = Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
            }

            return(response);
        }
        public async Task SetRotor_ShouldReturn200Ok_WhenSettingRotor2ToZ()
        {
            // Arrange
            var      controller = new EnigmaController("http://localhost:61467/", "api/Enigma/SetRotor/1", null);
            RotorDto rotorDto   = new RotorDto()
            {
                RotorNum           = 1,
                InitialDialSetting = 'a'
            };

            // Act
            HttpResponseMessage response =
                await controller.ExecutePostSetRotor <RotorDto, HttpResponseMessage>(rotorDto);

            // Assert
            HttpStatusCode statusCode    = response.StatusCode;
            string         encryptedText = await response.Content.ReadAsStringAsync();

            Assert.AreEqual(HttpStatusCode.OK, statusCode);
        }