コード例 #1
0
        public async Task Languages_Update_DoesUpdate()
        {
            //Arrange

            languages language = new languages
            {
                Description = Guid.NewGuid().ToString(),
                Name        = Guid.NewGuid().ToString()
            };
            await language.Create(dbContext).ConfigureAwait(false);

            //Act
            DateTime?oldUpdatedAt   = language.UpdatedAt;
            string   oldDescription = language.Description;
            string   oldName        = language.Name;

            language.Description = Guid.NewGuid().ToString();
            language.Name        = Guid.NewGuid().ToString();
            await language.Update(dbContext).ConfigureAwait(false);


            List <languages>         languages        = dbContext.languages.AsNoTracking().ToList();
            List <language_versions> languageVersions = dbContext.language_versions.AsNoTracking().ToList();

            Assert.NotNull(languages);
            Assert.NotNull(languageVersions);

            Assert.AreEqual(1, languages.Count());
            Assert.AreEqual(2, languageVersions.Count());

            Assert.AreEqual(language.CreatedAt.ToString(), languages[0].CreatedAt.ToString());
            Assert.AreEqual(language.Version, languages[0].Version);
//            Assert.AreEqual(language.UpdatedAt.ToString(), languages[0].UpdatedAt.ToString());
            Assert.AreEqual(languages[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(language.Id, languages[0].Id);
            Assert.AreEqual(language.Description, languages[0].Description);
            Assert.AreEqual(language.Name, languages[0].Name);

            //Old Version
            Assert.AreEqual(language.CreatedAt.ToString(), languageVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, languageVersions[0].Version);
//            Assert.AreEqual(oldUpdatedAt.ToString(), languageVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(languageVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(language.Id, languageVersions[0].LanguageId);
            Assert.AreEqual(oldDescription, languageVersions[0].Description);
            Assert.AreEqual(oldName, languageVersions[0].Name);

            //New Version
            Assert.AreEqual(language.CreatedAt.ToString(), languageVersions[1].CreatedAt.ToString());
            Assert.AreEqual(language.Version, languageVersions[1].Version);
//            Assert.AreEqual(language.UpdatedAt.ToString(), languageVersions[1].UpdatedAt.ToString());
            Assert.AreEqual(languageVersions[1].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(language.Id, languageVersions[1].LanguageId);
            Assert.AreEqual(language.Description, languageVersions[1].Description);
            Assert.AreEqual(language.Name, languageVersions[1].Name);
        }
コード例 #2
0
        public async Task languages_Update_DoesUpdate()
        {
            // Arrange
            string name        = Guid.NewGuid().ToString();
            string description = Guid.NewGuid().ToString();

            languages language = new languages
            {
                Name        = name,
                Description = description
            };


            await language.Create(dbContext).ConfigureAwait(false);

            // Act

            string newName        = Guid.NewGuid().ToString();
            string newDescription = Guid.NewGuid().ToString();

            language.Name        = newName;
            language.Description = newDescription;
            await language.Update(dbContext).ConfigureAwait(false);

            languages         dbLanguage        = dbContext.languages.AsNoTracking().First();
            language_versions dbLanguageVersion = dbContext.language_versions.AsNoTracking().First();

            // Assert
            Assert.NotNull(dbLanguage);
            Assert.NotNull(dbLanguageVersion);

            Assert.AreNotEqual(name, dbLanguage.Name);
            Assert.AreNotEqual(description, dbLanguage.Description);
            Assert.AreEqual(newName, dbLanguage.Name);
            Assert.AreEqual(newDescription, dbLanguage.Description);
        }