Esempio n. 1
0
        public async Task CreateSheriffSameIdir()
        {
            var newSheriff = new Sheriff
            {
                FirstName      = "Ted",
                LastName       = "Tums",
                BadgeNumber    = "556",
                Email          = "*****@*****.**",
                Gender         = Gender.Female,
                IdirId         = new Guid(),
                IdirName       = "ted@fakeidir",
                HomeLocationId = null
            };

            var sheriffDto = newSheriff.Adapt <SheriffWithIdirDto>();
            //Debug.Write(JsonConvert.SerializeObject(sheriffDto));

            var response        = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(await _controller.AddSheriff(sheriffDto));
            var sheriffResponse = response.Adapt <Sheriff>();

            Assert.NotNull(await Db.Sheriff.FindAsync(sheriffResponse.Id));

            newSheriff.BadgeNumber = "554";
            sheriffDto             = newSheriff.Adapt <SheriffWithIdirDto>();
            //Debug.Write(JsonConvert.SerializeObject(sheriffDto));

            BusinessLayerException ble = null;

            try
            {
                response = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(
                    await _controller.AddSheriff(sheriffDto));
                sheriffResponse = response.Adapt <Sheriff>();
            }
            catch (Exception e)
            {
                Assert.True(e is BusinessLayerException);
                ble = (BusinessLayerException)e;
            }

            Assert.Contains("has IDIR name", ble.Message);
        }
Esempio n. 2
0
        public async Task CreateSheriff()
        {
            var newSheriff = new Sheriff
            {
                FirstName      = "Ted",
                LastName       = "Tums",
                BadgeNumber    = "555",
                Email          = "*****@*****.**",
                Gender         = Gender.Female,
                IdirId         = new Guid(),
                IdirName       = "ted@fakeidir",
                HomeLocationId = null
            };

            var sheriffDto = newSheriff.Adapt <SheriffWithIdirDto>();
            //Debug.Write(JsonConvert.SerializeObject(sheriffDto));

            var response        = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(await _controller.AddSheriff(sheriffDto));
            var sheriffResponse = response.Adapt <Sheriff>();

            Assert.NotNull(await Db.Sheriff.FindAsync(sheriffResponse.Id));
        }