示例#1
0
        public async Task Put_Should_Update_Profile()
        {
            var postObj = new Profile
            {
                Id          = 1,
                Email       = "*****@*****.**",
                FirstName   = "Julius2",
                LastName    = "Koronci2",
                PhoneNumber = "0767654430",
                WebSite     = "www.web-solutions.sk"
            };

            var response = await Client.PutAsync("/api/profile/1",
                                                 new StringContent(JsonConvert.SerializeObject(postObj), Encoding.UTF8)
            {
                Headers = { ContentType = new MediaTypeHeaderValue("application/json") }
            });

            response.EnsureSuccessStatusCode();

            var updatedProfileResponse = await Client.GetAsync("/api/Profile/1");

            var profile =
                JsonConvert.DeserializeObject <Profile>(await updatedProfileResponse.Content.ReadAsStringAsync());

            AuditableTest.EnsureModifiedAuditableEntity(profile);
            AuditableTest.EqualsIgnoreAuditableProps(profile, postObj);
        }
示例#2
0
        public async Task Get_Should_Return_Profile()
        {
            var response = await Client.GetAsync("/api/Profile/1");

            response.EnsureSuccessStatusCode();
            var content = await response.Content.ReadAsStringAsync();

            var profile = JsonConvert.DeserializeObject <Profile>(content);

            AuditableTest.EnsureNotModifiedAuditableEntity(profile);
            AuditableTest.EqualsIgnoreAuditableProps(profile, Utilities.GetTestProfile());
        }
示例#3
0
        public void AddAuditInformation_IdIsNotZero_SetsObectStateUpdateDateAndUser()
        {
            // Arrange
            _auditable.Id = 1;

            //Act
            _auditable = _addAuditInformationOperation.Execute(_auditable);

            //Assert
            Assert.IsTrue(_auditable.Id == 1);
            Assert.IsTrue(_auditable.UpdateDate != null);
            Assert.IsTrue(_auditable.CreateDate == DateTime.MinValue);
            Assert.IsTrue(_auditable.UpdateUser == _testUser);
            Assert.IsTrue(string.IsNullOrEmpty(_auditable.CreateUser));
            Assert.IsTrue(_auditable.ObjectState == ObjectState.None);
        }
示例#4
0
 public void Setup()
 {
     _auditable = new AuditableTest();
     _addAuditInformationOperation = new AddAuditInformation <AuditableTest>();
     Thread.CurrentPrincipal       = new GenericPrincipal(new GenericIdentity(_testUser), new[] { "Administrator" });
 }