Skip to content

Commit

Permalink
Merge branch 'feature/Framework_management' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
iamfreid committed Apr 25, 2020
2 parents dac61aa + 2fdf81f commit 7b084e9
Show file tree
Hide file tree
Showing 16 changed files with 512 additions and 591 deletions.
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ and support existing ones.

###### View class
```
[View(alias: "Main Google page")]
public class MainGooglePage:View
{
public MainGooglePage()
Expand Down Expand Up @@ -97,20 +96,12 @@ public class Button:Control
```
[TestFixture]
public class Hooks
{
private TwinkleView _twinkleView;
[SetUp]
public void SetUp()
{
_twinkleView = new TwinkleView();
}
{
[Test]
public void ExecuteOperationWithPreHook()
{
_twinkleView.GetView<MainGooglePage>().SearchInput.SetValue("value");
_twinkleView.GetView<MainGooglePage>().SearchInGoogle.Click();
TwinkleView.GetView<MainGooglePage>().SearchInput.SetValue("value");
TwinkleView.GetView<MainGooglePage>().SearchInGoogle.Click();
}
}
```
Expand Down
4 changes: 0 additions & 4 deletions Twinkle.View.Test/Infrastructure/Controls/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ namespace Twinkle.View.Test.Infrastructure.Controls
{
public class Button:Control
{
public Button(string alias, string xpath, string css, TwinkleView twinkleView) : base(alias, xpath, css, twinkleView)
{
}

[Operation(Alias = "Click")]
public void Click()
{
Expand Down
5 changes: 0 additions & 5 deletions Twinkle.View.Test/Infrastructure/Controls/TextBox.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using Twinkle.View.Attributes;

namespace Twinkle.View.Test.Infrastructure.Controls
{
public class TextBox:Control
{
public TextBox(string alias, string xpath, string css, TwinkleView twinkleView) : base(alias, xpath, css, twinkleView)
{
}

[Operation(Alias = "SetValue")]
public void SetValue(string value)
{
Expand Down
1 change: 0 additions & 1 deletion Twinkle.View.Test/Infrastructure/Views/MainGooglePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Twinkle.View.Test.Infrastructure.Views
{
[View(alias: "Main Google page")]
public class MainGooglePage:View
{
public MainGooglePage()
Expand Down
16 changes: 5 additions & 11 deletions Twinkle.View.Test/Tests/Hooks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading;
using NUnit.Framework;
using Twinkle.View.Test.Infrastructure.Views;

Expand All @@ -7,32 +8,25 @@ namespace Twinkle.View.Test.Tests
[TestFixture]
public class Hooks
{
private TwinkleView _twinkleView;

[SetUp]
public void SetUp()
{
_twinkleView = new TwinkleView();
}

[Test]
public void ExecuteOperationWithPreHook()
{
var exceptionPre = Assert.Throws<Exception>(() => _twinkleView.GetView<MainGooglePage>().SearchInput.SetValue("value"));
TwinkleView.Context.Set("threadId", Thread.CurrentThread.ManagedThreadId);
var exceptionPre = Assert.Throws<Exception>(() => TwinkleView.GetView<MainGooglePage>().SearchInput.SetValue("value"));
Assert.That(exceptionPre.Message.Equals("before set value for search input"));
}

[Test]
public void ExecuteOperationWithPostHook()
{
var exception = Assert.Throws<Exception>(() => _twinkleView.GetView<MainGooglePage>().SearchInput.GetValue());
var exception = Assert.Throws<Exception>(() => TwinkleView.GetView<MainGooglePage>().SearchInput.GetValue());
Assert.That(exception.Message.Equals("after get value for search input"));
}

[Test]
public void ExecuteOperationWithoutHook()
{
Assert.DoesNotThrow(() => _twinkleView.GetView<MainGooglePage>().SearchInGoogle.Click());
Assert.DoesNotThrow(() => TwinkleView.GetView<MainGooglePage>().SearchInGoogle.Click());
}
}
}
2 changes: 1 addition & 1 deletion Twinkle.View.Test/TwinkleViewSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"dll_containing_controls": "Twinkle.View.Test"
},
"common": {
"logging_enable": false
"logging_enable": true
}
}
6 changes: 3 additions & 3 deletions Twinkle.View/Attributes/OperationAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class OperationAttribute : TwinkleBaseAttribute, IMethodDecorator
/// Alias operations
/// </summary>
public string Alias { get; set; }

/// <summary>
/// Control method marked with Operation attribute
/// </summary>
Expand Down Expand Up @@ -51,7 +51,7 @@ public void OnEntry()
{
//todo Check configuration parameter "automatic_view_detection"
ClearActiveViews();
((TwinkleView)_instanse.GetType().GetProperty("TwinkleView").GetValue(_instanse)).GetActiveViews();
TwinkleView.InternalTwinkleView.GetActiveViews();
FindHooks(true);
}

Expand All @@ -60,7 +60,7 @@ public void OnEntry()
/// </summary>
private void ClearActiveViews()
{
var activeViews = ((TwinkleView)_instanse.GetType().GetProperty("TwinkleView").GetValue(_instanse)).SystemContext.Views.ActiveViews;
var activeViews = TwinkleView.InternalTwinkleView.SystemContext.Views.ActiveViews;
if (activeViews != null)
activeViews.Clear();
}
Expand Down
10 changes: 0 additions & 10 deletions Twinkle.View/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,5 @@ public abstract class Control
public string XPath { get; set; }
public string Css { get; set; }
public List<Hook> Hooks { get; set; }
public TwinkleView TwinkleView { get; set; }

public Control(string alias, string xpath, string css, TwinkleView twinkleView)
{
Alias = alias;
XPath = xpath;
Css = css;
TwinkleView = twinkleView;
}

}
}
14 changes: 7 additions & 7 deletions Twinkle.View/Infrastructure/GlobalConfiguraionFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

namespace Twinkle.View.Infrastructure
{
internal class GlobalConfiguraionFramework
public class GlobalConfiguraionFramework
{
internal bool AutomaticViewDetection { get; set; }
internal List<string> DllContainingViews { get; set; }
internal List<string> DllContainingControls { get; set; }
internal int SearchControlNumberOfRetries { get; set; }
internal int SearchControlTimeBetweenRetries { get; set; }
internal bool LoggingEnable { get; set; }
public bool AutomaticViewDetection { get; internal set; }
public List<string> DllContainingViews { get; internal set; }
public List<string> DllContainingControls { get; internal set; }
public int SearchControlNumberOfRetries { get; internal set; }
public int SearchControlTimeBetweenRetries { get; internal set; }
public bool LoggingEnable { get; internal set; }

public GlobalConfiguraionFramework(IConfiguration config)
{
Expand Down
Loading

0 comments on commit 7b084e9

Please sign in to comment.