public IUnitTestElement GetOrCreateTestElement(
            string elementTypeFullName,
            ITestEntity entity,
            [CanBeNull] IUnitTestElement parentElement)
        {
            var factory = _factoryMethods[elementTypeFullName];
            var element = factory(entity);

            element.Parent = parentElement;
            return(element);
        }
示例#2
0
        private IUnitTestElement GetOrCreateAndUpdateElement(
            ITestEntity testEntity,
            Func <ITestIdentity, ITestElement> factory)
        {
            var identity = new TestIdentity(_testProvider, testEntity.Project, testEntity.Identity, _unitTestElementIdFactory);
            var element  = _unitTestElementManager.GetElementByIdentity(identity) ?? factory(identity);

            element.Update(testEntity.Text, null, Enumerable.Empty <UnitTestElementCategory>());

            return(element);
        }
示例#3
0
        public IUnitTestElement GetOrCreateClassTestElementRecursively(ITestEntity testEntity)
        {
            var element = GetOrCreateAndUpdateElement(
              testEntity,
              identity =>
              new ClassTestElement(
                  identity,
                  new Task[] { new RunTask(), new AssemblyTask(identity.Parent), new TestTask(identity) }));

              CreateAndAppendChildren(element, testEntity);
              return element;
        }
        private IUnitTestElement GetOrCreateAndUpdateElement(
            ITestEntity testEntity,
            Func <ITestIdentity, ITestElement> factory)
        {
            var elementId = _unitTestElementIdFactory.Create(_testProvider, testEntity.Project, testEntity.Identity.Absolute);
            var identity  = new TestIdentity(elementId, testEntity.Identity);
            var element   = _unitTestElementManager.GetElementByIdentity(identity) ?? factory(identity);

            element.Update(testEntity.Text, explicitReason: null, categories: testEntity.Categories.Select(x => _unitTestElementCategoryFactory.Create(x)));

            return(element);
        }
        public IUnitTestElement GetOrCreateClassTestElementRecursively(ITestEntity testEntity)
        {
            var element = GetOrCreateAndUpdateElement(
                testEntity,
                identity =>
                new ClassTestElement(
                    identity,
                    new Task[] { new RunTask(), new AssemblyTask(identity.Parent.NotNull()), new TestTask(identity) }));

            CreateAndAppendChildren(element, testEntity);
            return(element);
        }
示例#6
0
 private void CheckEntityEquals(ITestEntity entity, ITestEntity entity2)
 {
     Assert.Equal(entity.Integer, entity2.Integer);
     Assert.Equal(entity.IntegerNullable, entity2.IntegerNullable);
     Assert.Equal(entity.Double, entity2.Double);
     Assert.Equal(entity.DateTime, entity2.DateTime);
     Assert.Equal(entity.DateTimeNullable, entity2.DateTimeNullable);
     Assert.Equal(entity.DateTimeOffset, entity2.DateTimeOffset);
     Assert.Equal(entity.DateTimeOffsetNullable, entity2.DateTimeOffsetNullable);
     Assert.Equal(entity.TimeSpan, entity2.TimeSpan);
     Assert.Equal(entity.TimeSpanNullable, entity2.TimeSpanNullable);
     Assert.Equal(entity.String, entity2.String);
 }
示例#7
0
        private IUnitTestElement GetOrCreateAndUpdateElement(
            ITestEntity testEntity,
            Func <ITestIdentity, ITestElement> factory)
        {
            var elementId = _unitTestElementIdFactory.Create(
                _testProvider.ID,
                testEntity.Project.GetPersistentID(),
                // TODO: TargetFrameworkId
                TargetFrameworkId.Default,
                testEntity.Identity.Absolute);
            var identity = new TestIdentity(elementId, testEntity.Identity);
            var element  = _unitTestElementManager.GetElementById(identity.ElementId) as ITestElement ?? factory(identity);

            element.Update(testEntity.Text, explicitReason: null, categories: testEntity.Categories.Select(x => _unitTestElementCategoryFactory.Create(x)));

            return(element);
        }
示例#8
0
 private void CheckEntityEquals(ITestEntity entity)
 {
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.Integer)], entity.Integer);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.IntegerNullable)], entity.IntegerNullable);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.Double)], entity.Double);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.DateTime)], entity.DateTime);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.DateTimeNullable)], entity.DateTimeNullable);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.DateTimeOffset)], entity.DateTimeOffset);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.DateTimeOffsetNullable)], entity.DateTimeOffsetNullable);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.TimeSpan)], entity.TimeSpan);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.TimeSpanNullable)], entity.TimeSpanNullable);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.String)], entity.String);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.Object)], entity.Object);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.EnumValue)], entity.EnumValue);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.Values)], entity.Values);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.ValuesInt)], entity.ValuesInt);
     Assert.Equal(DefaultTestEntity[nameof(ITestEntity.GuidValue)], entity.GuidValue);
 }
示例#9
0
 private IUnitTestElement GetOrCreateChildTest(ITestEntity testEntity)
 {
     return GetOrCreateAndUpdateElement(
       testEntity,
       identity => new ChildTestElement(identity, new Task[] { new TestTask(identity) }));
 }
示例#10
0
        private IUnitTestElement GetOrCreateAndUpdateElement(
        ITestEntity testEntity,
        Func<ITestIdentity, ITestElement> factory)
        {
            var elementId = _unitTestElementIdFactory.Create(_testProvider, testEntity.Project, testEntity.Identity.Absolute);
              var identity = new TestIdentity(elementId, testEntity.Identity);
              var element = _unitTestElementManager.GetElementByIdentity(identity) ?? factory(identity);

              element.Update(testEntity.Text, null, testEntity.Categories.Select(x => _unitTestElementCategoryFactory.Create(x)));

              return element;
        }
示例#11
0
 private void CreateAndAppendChildren(IUnitTestElement testElement, ITestEntity testEntity)
 {
     testEntity.TestEntities.Select(GetOrCreateChildTest).ForEach(x => x.Parent = testElement);
 }
示例#12
0
 public string PrintAddResult(ITestEntity entity)
 {
     return(string.Format("程序计算结果:{0}", MyApp.Bll.Test.AddWith10(entity)));
 }
示例#13
0
 private void CreateAndAppendChildren(IUnitTestElement testElement, ITestEntity testEntity)
 {
     testEntity.TestEntities.Select(GetOrCreateChildTest).ForEach(x => x.Parent = testElement);
 }
示例#14
0
 private IUnitTestElement GetOrCreateChildTest(ITestEntity testEntity)
 {
     return(GetOrCreateAndUpdateElement(
                testEntity,
                identity => new ChildTestElement(identity, new Task[] { new TestTask(identity) })));
 }
示例#15
0
 public IUnitTestElement GetOrCreateTestElement(
 string elementTypeFullName,
 ITestEntity entity,
 [CanBeNull] IUnitTestElement parentElement)
 {
     var factory = _factoryMethods[elementTypeFullName];
       var element = factory(entity);
       element.Parent = parentElement;
       return element;
 }
示例#16
0
        public static async Task Action(HttpClient httpClient, string baseUrl, string url, string actionVerb, string username, string password, ITestEntity record)
        {
            // arrange
            var loginResponse = await Helpers.Login(httpClient, Helpers.CreateLoginCredentials(username, password));

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(JwtBearerDefaults.AuthenticationScheme, loginResponse.Token);
            var request = Helpers.CreateRequest(baseUrl, url);
            // act
            var actionResponse = new HttpResponseMessage();

            switch (actionVerb)
            {
            case "get":
                actionResponse = await httpClient.SendAsync(request);

                break;

            case "post":
                actionResponse = await httpClient.PostAsync(baseUrl + url, new StringContent(System.Text.Json.JsonSerializer.Serialize(record), Encoding.UTF8, MediaTypeNames.Application.Json));

                break;

            case "put":
                actionResponse = await httpClient.PutAsync(baseUrl + url, new StringContent(System.Text.Json.JsonSerializer.Serialize(record), Encoding.UTF8, MediaTypeNames.Application.Json));

                break;

            case "patch":
                actionResponse = await httpClient.PatchAsync(baseUrl + url, new StringContent(System.Text.Json.JsonSerializer.Serialize(record), Encoding.UTF8, MediaTypeNames.Application.Json));

                break;

            case "delete":
                actionResponse = await httpClient.DeleteAsync(baseUrl + url);

                break;
            }
            // cleanup
            await Helpers.Logout(httpClient, loginResponse.UserId);

            // assert
            Assert.Equal(HttpStatusCode.Forbidden, actionResponse.StatusCode);
        }
示例#17
0
        private void PrepareEntity(ITestEntity entity)
        {
            entity.CopyProperties(DefaultTestEntity);

            entity.WriteonlyInt = 1;
        }