How to implement IXunitTestCollectionFactory - xunit

I can't find any docs on using/implementing IXunitTestCollectionFactory.
I have some custom logic on how I want to resolve the existence of some test cases, from rummaging in the xunit source/samples, this seems to be the way to go.
public class Foo : IXunitTestCollectionFactory
{
public Foo(ITestAssembly assembly, IMessageSink messageSink)
{
throw new NotImplementedException();
}
public ITestCollection Get(ITypeInfo testClass)
{
throw new NotImplementedException();
}
public string DisplayName
{
get { throw new NotImplementedException(); }
}
}
This doesn't ever seem to get run, or at least the exceptions are swallowed and any real code I put in there doesn't seem to be run either.
I've tried adding this to the test assembly, but to no avail
[assembly: CollectionBehavior("MyAssembly.Foo", "MyAssembly")]
Where do I start? Are there any docs on this anywhere?

This:
[assembly: CollectionBehavior("MyAssembly.Foo", "MyAssembly")]
Should be this:
[assembly: CollectionBehavior("MyNamespace.Foo", "MyAssembly")]

Related

ObservableCollection made of strings Not updating

Ok, so, I'm trying to link an ObservableCollection from my Android project to my Cross-Platform Project::
I've got this so far...this is in my Cross-platform app
ObservableCollection<String> NewRef = DependencyService.Get<ISlateBluetoothItems>().test().testThing;
NewRef.CollectionChanged += TestThing_CollectionChanged;
listView.ItemsSource = NewRef;
private void TestThing_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
listView.ItemsSource = DependencyService.Get<ISlateBluetoothItems>().test().testThing;
Console.WriteLine("working");
}
The line "working" is never printed even if I make changes to the ObservableCollection on the android portion of my app...
Here's the interface I'm using for the DependencyService:
using System.Collections.ObjectModel;
namespace ThoughtCastRewrite.BluetoothX
{
public interface ISlateBluetoothItems
{
BluetoothItems test();
}
}
Here's the class I use to expose the list:
namespace ThoughtCastRewrite.BluetoothX
{
public class BluetoothItems
{
public ObservableCollection<String> testThing;
public BluetoothItems()
{
testThing = new ObservableCollection<String>();
testThing.Add("wtf?");
}
public void AddThis()
{
testThing.Add("ok");
}
}
}
This is in the Android portion of my app, it implements the ISlateBluetoothItems interface
BluetoothItems bluetoothItems = new BluetoothItems();
then I call
bluetoothItems.AddThis();
but "ok" is not added to my list! I don't get the CollectionChanged event firing off! What's the deal guys? What's the deal?
You should assign your ObservableCollection as a source of your listview only once, not after each change. Changes to the collection will be automaticcly propagated to the listview.

Getting Java.Lang.NullPointerException when trying to open GPS Settings page using Xamarin

I am getting the following error when trying to open GPS settings page if GPS is not enabled (within Xamarin):
Unknown identifier: StartActivity
Unhandled Exception:
Java.Lang.NullPointerException:
Can somebody please guide where am I getting wrong?
This My Interface
namespace MyApp
{
public interface GpsSettings
{
void showGpsSettings();
}
}
This the Implementation
[assembly: Xamarin.Forms.Dependency(typeof(GpsSettingsImplementation))]
namespace MyApp.Droid
{
public class GpsSettingsImplementation : Activity, GpsSettings
{
public GpsSettingsImplementation()
{
}
public void showGpsSettings()
{
var intent = new Intent(Android.Provider.Settings.ActionLocationSourceSettings);
StartActivity(intent);
}
}
}
This is how I call my function on button click
DependencyService.Get<GpsSettings>().showGpsSettings();
An existing Activity instance has a bit of work that goes on behind
the scenes when it's constructed; activities started through the
intent system (all activities) will have a Context reference added to
them when they are instantiated. This context reference is used in the
call-chain of StartActivity.
So, the Java.Lang.NullPointerException seen after invoking
StartActivity on your Test activity instance is because the Context
inside that instance has never been set. By using the new operator to
create an activity instance you've circumvented the normal way
activities are instantiated, leaving your instance in an invalid
state!
ref: https://stackoverflow.com/a/31330999/5145530
The above error can be resolved in the following manner:
[assembly: Xamarin.Forms.Dependency(typeof(GpsSettingsImplementation))]
namespace MyApp.Droid
{
public class GpsSettingsImplementation : Activity, GpsSettings
{
public GpsSettingsImplementation()
{
}
public void showGpsSettings()
{
var intent = new Intent(Android.Provider.Settings.ActionLocationSourceSettings);
intent.SetFlags(ActivityFlags.NewTask);
Android.App.Application.Context.StartActivity(intent);
}
}
}

Examples of how to use NServiceBus with NServiceBus.Ninject-CI in ASP.NET MVC 3 solution

I would like to experiment with NServiceBus using ASP.NET MVC 3. I've got a solution with NServiceBus installed, plus NinjectMVC3 and NServiceBus.Ninject-CI. Trouble is, I have no idea how to setup NServiceBus stuff in the NinjectMVC3.cs file in App_Start.
Rather annoyingly I'm having trouble finding any examples of how to use NServiceBus.Ninject-CI (I hate it when people don't bother giving examples of how to use their stuff).
Can someone help me get started please?
Load a module like this into the kernel to provide access to the bus
public class NServiceBusModule : NinjectModule
{
public override void Load()
{
this.Bind<IBus>().ToConstant(this.CreateBus()).InSingletonScope();
}
private IBus CreateBus()
{
return NServiceBus.Configure.WithWeb()
.NinjectBuilder(this.Kernel)
... // put NServiceBus config here
.CreateBus()
.Start();
}
}
Read the NServiceBus documentation about how to configure NServiveBus:
http://docs.particular.net/nservicebus/containers/ninject
http://docs.particular.net/samples/web/asp-mvc-application/
Hopefully this will help someone. I had a lot of trouble finding sample code for getting ninject working within NServiceBus.
This code below works for me in place of the more common Castle version:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
#region IWantCustomInitialization Members
public void Init()
{
Configure
.With()
.NinjectBuilder(CreateKernel())
.XmlSerializer()
.MsmqTransport();
SetLoggingLibrary.Log4Net(XmlConfigurator.Configure);
}
protected IKernel CreateKernel()
{
var kernel = new StandardKernel();
kernel.Load<MyCustomNinjectModule>();
return kernel;
}
#endregion
}
with the ninject module being the usual format, ie:
public class MyCustomNinjectModule : NinjectModule
{
public override void Load()
{
Bind(typeof(ILogger<>)).To(typeof(Log4NetLogger<>));
...
}
}

Cocoa: PhotoshopImage class and resize

Does anyone knows how i can resize the PhotoshopImage instance?
I don't us the UIImageView because i need to load a lot of images and the PhotoshopImage class handles it better.
Got a real shaky start for you! Photoshop has documentation on using javascript vbscript with photoshop dll's: http://www.adobe.com/devnet/photoshop/scripting.html. These same methods are exposed via COM to C# and I wonder if they're available to Objective-C (RedGate and the vs object browser can help if you dabble with it). Don't cringe at the C# code! The point is photoshop exposes dlls which can be worked with. C# ASP.NET exposes photoshop .dll's via COM. I'm new to objective-c and not a vet at C#! I got this code to work on my windows machine in C#. This code cranks up a web page and fires up my version of photoshop cs3 and goes thru my directory of files and creates an "Adobe image gallery". Good luck to you and post back what you find in objective-c...I think objective-c can run native C and I've seen some documentation of working with photoshop in native C...Shoot some code back either way...I'm a semi newbie so if this wasn't what you meant by Photoshop Image I apologize!
CDUB
PS these are all photoshop methods being exposed, nothing I made up...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GoogleTalkAPILib;
using ps = Photoshop;
using Photoshop;
namespace photoshop
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
Object ob= null;
//works!!!!!!
// co.Application.MakePDFPresentation(oaa,
"C:\Users\Photoshoptryrescl",ob);
//you can also use c# to run a javascript
// co.DoJavaScript("hey.js",e,d );
co.MakePhotoGallery(oab, "C:\\photoshopdump", ob);
}
catch (Exception ex)
{ Trace.Write(ex.Message.ToString()); }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ps = Photoshop;
using Photoshop;
using Microsoft.Win32.SafeHandles;
using Microsoft.Win32;
using Microsoft;
namespace photoshop
{
public delegate void addBlur();
public class Class1 : ApplicationClass, ArtLayer, Document
{
public Class1()
{ }
public void addBlur()
{ }
public void addBlur1(string sa)
{ }
#region ArtLayer Members
public void AdjustBrightnessContrast(int Brightness, int Contrast)
{
throw new NotImplementedException();
}
public void AdjustColorBalance(object Shadows, object Midtones, object Highlights, object PreserveLuminosity)
{
throw new NotImplementedException();
}
public void AdjustCurves(object CurveShape)
{
throw new NotImplementedException();
}
public void AdjustLevels(int InputRangeStart, int InputRangeEnd, double InputRangeGamma, int OutputRangeStart, int OutputRangeEnd)
{
throw new NotImplementedException();
}
public bool AllLocked
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public void ApplyAddNoise(double Amount, PsNoiseDistribution Distribution, bool Monochromatic)
{
throw new NotImplementedException();
}
public void ApplyAverage()
{
throw new NotImplementedException();
}
public void ApplyBlur()
{
// throw new NotImplementedException();
}
public void ApplyBlurMore()
{
throw new NotImplementedException();
}
//etc... these interfaces expose a ton of methods which can be explicity implemented
//this isn't them all

Plug-in Development: Creating Problem Marker for a Given Resource

I seem to be having a problem with associating a problem marker with a resource; in my case, I'm trying to create a problem marker for the editor.
To achieve this, I've tried to do the following:
public class MyEditor extends TextEditor{
private ColorManager colorManager;
public MyEditor() {
super();
...
IResource resource = (IResource) getEditorInput().getAdapter(IResource.class);
try
{
marker = resource.createMarker(IMarker.PROBLEM);
}
catch (CoreException e)
{
e.printStackTrace();
}
}
However, the problem is getEditorInput() keeps returning null. I assume I am not calling it at the right location. I thought it would be ideal to create the marker once I'm setting up the editor, but this proves otherwise.
Does anyone have any advice to obtaining the proper resource I want so that I may create the problem marker? I would like to show errors and such within the editor.
I've looked at samples online for creating the marker, but most just show methods that pass the ITextEditor object without showing where the method call is. (for example: Creating Error Marker for Compiler -- see reportError method)
Thank you.
Paul
Edit:
I have also viewed the following link regarding problem markers, but again, it calls createMarker from a resource(res, in this case), but does not show the setup for it.
See Show Syntax Errors in An Eclipse Editor Plugin
EditorInput is initialize in init method
You can override init or
public class MyEditor extends TextEditor{
private ColorManager colorManager;
public MyEditor() {
super();
...
}
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
super.init(site, input);
IResource resource = (IResource) getEditorInput().getAdapter(IResource.class);
try
{
marker = resource.createMarker(IMarker.PROBLEM);
}
catch (CoreException e)
{
e.printStackTrace();
}
}
I create a marker (including a call to getEditorInput()) from the run() method of an Action object.
public class MyAction extends Action {
...
public void run() {
...
int line = ...;
IEditorInput ei = editor.getEditorInput()
if (ei != null)
createMarkerAt(line, ei);
}
}
Addition (Following Paul's comment) How to get an Editor?
Well, In my app I am subclassing AbstractRulerActionDelegate, by overriding the createAction(ITextEditor e, IVerticalRulerInfo ri) method (which, BTW, Is a must - this method is abstract) my app can get the relevant ITextEditor object.

Resources