Error in executing the Xamarin.UITest for some reason - xamarin

I am trying to do UI Testing using the Xamarin.UITest framework. I am trying to follow the procedure using the links that is given on their website.The application is named 'CreditCardValidator'. I downloaded the app and then did stuffs like upgrading the UITest package and not the NUnit package. As the tutorial mentions that the code that is to be mentioned is
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.iOS;
using Xamarin.UITest.Queries;
namespace CreditCardValidator.iOS.UITests
{
[TestFixture]
public class Tests
{
iOSApp app;
[SetUp]
public void BeforeEachTest()
{
Console.WriteLine ("Starting the function");
app = ConfigureApp.iOS.StartApp();
// app = ConfigureApp.iOS.AppBundle("/Users/admin/Library/Developer/CoreSimulator/Devices/57DBB268-714A-473F-A7D3-C3B4BB2BB138/data/Containers/Bundle/Application/A9151B5D-7B9C-4F9A-9EF2-F153AC994170").StartApp();
Console.WriteLine ("ending the function ");
}
[Test]
public void CreditCardNumber_TooShort_DisplayErrorMessage()
{
Console.WriteLine ("Starting the function");
app.WaitForElement(c=>c.Class("UINavigationBar").Marked("Simple Credit Card Validator"));
app.EnterText(c=>c.Class("UITextField"), new string('9', 15));
Console.WriteLine ("ending the function ");
}
}
}
MY PROBLEM :
The simulator is not opening and the tests are failing for no reason. The StartApp() functions documentation says that it LAUNCHES the app on the simulator. The error I am getting in the Test Results pad is
SetUp : System.NullReferenceException : Object reference not set to an instance of an object
They are failing at the line : app = ConfigureApp.iOS.StartApp();
I tried to replace this line with the compiled version of the app which is commented out in the code. But for that still the simulator is not opening and the error I am getting is
SetUp : System.Exception : App bundle directory doesn't contain a valid app bundle. Still the error is at the Startup function line
MORE INFO : In the second attempt I found that my .app file has a 'STOP' image on it. Could this be the reason ?
Please ask if more information is required.

Related

Xamarin - iOS MFMailComposeViewController.CanSendMail results in 'Got a segv while executing native code'

I'm trying to send an e-mail from a Xamarin Forms app using an iOS code with DependencyInjection which looks like this:
[assembly: Xamarin.Forms.Dependency(typeof(SendMail))]
namespace SampleApp.iOS.PlatformSpecific
{
public class SendMail : ISendMail
{
public void SendMail()
{
Device.BeginInvokeOnMainThread(() =>
{
if (MFMailComposeViewController.CanSendMail) <-- crashes here
{
// my code
}
}
}
}
}
The line indicated above always crashes on a real device (but works on a simulator). The crash is the following:
=================================================================
Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Any ideas what could be wrong?

SfChart are not displaying on IOS and working properly in Android - Xamarin Forms

Syncfusion sfchart working fine in android but generating error in IOS. here is my AppDelegate class code
AppDelegate:
namespace ProjectName
{
[Register ("AppDelegate")]
public class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
new Syncfusion.SfChart.XForms.iOS.Renderers.SfChartRenderer();
global::Xamarin.Forms.Forms.Init ();
Appearance.Configure ();
LoadApplication (new App());
return base.FinishedLaunching (app, options);
}
}
}
If I remove 'new Syncfusion.SFChart.Xforms.IOS.Renderer.SfChartRenderer' from Code it run without generating any error or any result but when I put this line of code then it throw error which is
foundation.monotouchexception objective-c exception thrown
We were not able to reproduce the reported issue at our end and we have prepared a sample for this. Please check the attached sample.
Note: We suggest you to use Init method of SfChartRenderer as per the below code.
Code Example:
Syncfusion.SfChart.XForms.iOS.Renderers.SfChartRenderer.Init();
If you are still facing this issue, please update us the Xamarin Studio / Visual Studio version. Please download the sample from the following location.
Sample: http://www.syncfusion.com/downloads/support/forum/131907/ze/ChartGettingStarted1268455699
Regards,
Saravana Pandian M.

Compile C# on OSX using edge.js nuget package

So, I have this code from the edge.js instructions:
using System;
using System.Threading.Tasks;
using EdgeJs;
class Program
{
public static async void Start()
{
var func = Edge.Func(#"
return function (data, callback) {
callback(null, 'Node.js welcomes ' + data);
}
");
Console.WriteLine(await func(".NET"));
}
static void Main(string[] args)
{
Task.Run((Action)Start).Wait();
}
}
And I have nuget working so that I have installed edge.js with nuget install edge.js -o ./packages
But I can't figure out how to compile it on my Mac OSX. I've tried:
mcs -pkg:./packages program.cs
mcs -lib:./packages/Edgejs.0.10.0 program.cs
and a bunch other combinations. I always get this error:
error CS0246: The type or namespace name `EdgeJs' could not be found. Are you missing an assembly reference?
I have not tried monoDevelop yet. I'm hoping to get it to work with the mono command line tools so I don't need monoDevelop.
You can use -r to reference the Edgejs assembly.
mcs -r:./packages/Edge.js.0.10.0/lib/Edgejs.dll program.cs

Xamarin Monodevelop - Error CS0103

I just installed Xamarin Monodevelop on Mac OSX, I created a GTK# project where I have a very basic Window that I haven't even touched. This is the error it gives me on Build();
Error CS0103: The name 'Build' does not exist in the current context
using System;
using Gtk;
public partial class MainWindow: Gtk.Window
{
public MainWindow () : base (Gtk.WindowType.Toplevel)
{
Build ();
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
}
The Build method is created by the Stetic UI builder, akin to the InitializeComponents of the Visual Studio UI builder.
There seems to be a bug in Xamarin Studio (I'm using 5.5.4.15) where the Build method is not generated unless you add a widget to the Window. Try adding a VBox or another container and then rebuilding.

Renaming config files with Visual Studio setup project

My applications have a handful of config files, each one particular to the machine it's being deployed to (dev, production, etc.) I'm wanting to add them to the setup project, use radio buttons to select one and then have a script (or maybe custom action?) rename the selected files to connectionStrings.config, settings.config, etc.
Is this feasible/possible with a setup project?
To give you an idea, my configs might look like this:
DEV connectionStrings.config
PROD connectionStrings.config
After the user chooses DEV or PROD in the installer radiobutton UI, I would like the chosen config to be renamed to
connectionStrings.config
Considering it's a VS setup project, I have a feeling I'm asking for way too much and that I will get an interesting response as most setup project questions do :)
I created a setup project to set connection strings and i used the following which works perfectly for me.
Create a installer.cs file for the setup.
using System;
using System.Data.SqlClient;
using System.Xml;
using System.Configuration;
using System.Reflection;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.Configuration.Install;
namespace YOURNAMESPACE
{
[RunInstaller(true)]
public partial class installer : System.Configuration.Install.Installer
{
public installer()
{
InitializeComponent();
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
try
{
string DatabaseString1 = "FULL NAME OF CONNECTION STRING";
ConnectionConfigure(DatabaseString1);
}
catch (Exception e)
{
base.Rollback(savedState);
}
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
}
private void ConnectionConfigure(string DatabaseString)
{
string dataSource = "";
dataSource = "Provider="+ Context.Parameters["InitialCatalog"]+ ";" + "Data Source=" + Context.Parameters["DataSource"];
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
string configFile = string.Concat(Assembly.GetExecutingAssembly().Location, ".config");
map.ExeConfigFilename = configFile;
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.
OpenMappedExeConfiguration(map, System.Configuration.ConfigurationUserLevel.None);
string connectionsection = config.ConnectionStrings.ConnectionStrings
[DatabaseString].ConnectionString;
ConnectionStringSettings connectionstring = null;
if (connectionsection != null)
{
config.ConnectionStrings.ConnectionStrings.Remove(DatabaseString);
}
connectionstring = new ConnectionStringSettings(DatabaseString, dataSource);
config.ConnectionStrings.ConnectionStrings.Add(connectionstring);
config.Save(ConfigurationSaveMode.Modified, true);
ConfigurationManager.RefreshSection("connectionStrings");
}
}
}
Add project output to your setup project then begin to setup this setup project.
Right click setup project
Add text boxes and create the UI
Set custom actions
Create project output actions
Custom action properties
That is how i setup mine (I have attached screenshots to help explain my process but in short. Create setup project and installer.cs file. Add project output to setup project, add a UI so that the user can input a connection string and or provider for connection string, add custom actions so that the inputs can be read by the installer.cs file and then congratulations it should change the connection string.
Hope this helps.
I've come to the conclusion that this is impossible due to VS severely lacking on setup project configuration options. Instead I added a radio button control during the setup process and assigned the choices a variable name. In the file system I added all of my config files and then set conditions to each one. They referenced values to my radio button choices in order to copy during deployment.
I've done this many times, and basically I just install both files with different names. The application can ask the user which file to use, and change it anytime they want because many users don't know enough about the application to make this choice at install time.
You get interesting answers to setup questions like this because many people want to configure the application during the installation. Why not just let the setup install the files and have the app do its own configuration?

Resources